Writing Pact test in Scala

402 views
Skip to first unread message

Chuan Chuan Law

unread,
Jun 22, 2016, 3:33:47 PM6/22/16
to Pact
Hi,


I am trying to write a simple consumer test in Scala by following the example in https://github.com/ITV/scala-pact/blob/master/scalapact-scalatest/src/test/scala/com/itv/scalapact/ExampleSpec.scala which looks like:

import ScalaPactForger._
class ExampleSpec extends FunSpec with Matchers {
private implicit val formats = DefaultFormats
describe("Example CDC Integration tests") {
it("Should be able to create a contract for a simple GET") {
val endPoint = "/hello"
forgePact
.between("My Consumer")
.and("Their Provider Service")
.addInteraction(
interaction
.description("a simple get example")
.uponReceiving(endPoint)
.willRespondWith(200, "Hello there!")
)
.runConsumerTest { mockConfig =>



When I compile, I am getting compilation error that :

not found: object ScalaPactForger

[error] import ScalaPactForger._



May I know under which library does ScalaPactForger lives?


Thanks.

Chuan Chuan Law

unread,
Jun 22, 2016, 4:15:42 PM6/22/16
to Pact

This is solved by import com.itv.scalapact.ScalaPactForger.{ScalaPactMatchingRuleRegex, ScalaPactOptions, _}

Dave Smith

unread,
Aug 3, 2016, 3:18:19 AM8/3/16
to Pact
Hi,

Sorry I only just noticed this. You are correct, however you should just use _.

The example spec found here is actually misleading, because it's a test case in it's own project it doesn't need the fully qualified path - I hadn't thought of that when I wrote it!


So it just says:

import ScalaPactForger._

But as you said it should be:

import com.itv.scalapact.ScalaPactForger._

Cheers,

Dave

Dave Smith

unread,
Aug 14, 2016, 5:56:22 AM8/14/16
to Pact
I case anyone else is struggling, I've added a simple example setup to the project:

Reply all
Reply to author
Forward
0 new messages