Java pact-jvm-consumer-specs2-缺少:[错误]方法:获取

Java pact-jvm-consumer-specs2-缺少:[错误]方法:获取,java,scala,spec2,pact,pact-java,Java,Scala,Spec2,Pact,Pact Java,我对运行sbt的spec2使用者的Pact JVM有问题。 -有什么不对劲? -我没有生成任何pact文件 鉴于: 具有依赖项的sbt项目 “au.com.dius”%%“pact-jvm-consumer-specs2”%%“3.2.11” “org.specs2”%%“specs2 junit”%%“3.3.1” 我的等级是: import java.util.concurrent.TimeUnit.MILLISECONDS import akka.actor.ActorSystem

我对运行sbt的spec2使用者的Pact JVM有问题。 -有什么不对劲? -我没有生成任何pact文件

鉴于:

  • 具有依赖项的sbt项目

    “au.com.dius”%%“pact-jvm-consumer-specs2”%%“3.2.11”

    “org.specs2”%%“specs2 junit”%%“3.3.1”

我的等级是:

import java.util.concurrent.TimeUnit.MILLISECONDS

import akka.actor.ActorSystem
import akka.http.scaladsl.Http
import akka.http.scaladsl.model.HttpRequest
import akka.stream.ActorMaterializer
import au.com.dius.pact.consumer.PactSpec
import org.junit.runner.RunWith
import org.specs2.mutable.Specification
import org.specs2.runner.JUnitRunner

import scala.concurrent.duration._
import scala.concurrent.Await
import scala.concurrent.duration.Duration

@RunWith(classOf[JUnitRunner])
class PactClientSpec extends Specification with PactSpec {
  sequential

  override val provider: String = "SpecsProvider"
  override val consumer: String = "SpecsConsumer"


  implicit val actorSystem = ActorSystem()
  implicit val materializer = ActorMaterializer()
  implicit val dispatcher = actorSystem.dispatcher

  val timeout = Duration(5000, MILLISECONDS)

  override def is = uponReceiving("a request for foo")
    .matching(path = "/users/1234")
    .willRespondWith(body = "{}")
    .withConsumerTest { providerConfig =>

      val responseFuture= Http().singleRequest(HttpRequest(uri = s"http://${providerConfig.url}/users/1234"))
      val response = Await.result(responseFuture, 10 seconds)
      "Hello world" must endWith("world")
    }
}
当我使用sbt测试运行时,我得到:

x Consumer 'SpecsConsumer' has a pact with Provider 'SpecsProvider': a request for foo 2
[error]
[error]  missing:
[error]         method: GET
[error]         path: /users/1234
[error]         query: null
[error]         headers: [:]
[error]         matchers: [:]
[error]         body: au.com.dius.pact.model.OptionalBody(EMPTY, ) (PactSpec.scala:29)
[info] PactClientSpec
[info]
[info] Total for specification PactClientSpec
[info] Finished in 707 ms
[info] 1 example, 1 failure, 0 error
[info]
[info] ScalaCheck
[info] Passed: Total 0, Failed 0, Errors 0, Passed 0
[info] ScalaTest
[info] Run completed in 2 seconds, 562 milliseconds.
[info] Total number of tests run: 0
[info] Suites: completed 0, aborted 0
[info] Tests: succeeded 0, failed 0, canceled 0, ignored 0, pending 0
[info] No tests were executed.
[error] Failed: Total 1, Failed 1, Errors 0, Passed 0
[error] Failed tests:
[error]         PactClientSpec
[error] (token-manager/test:testOnly) sbt.TestsFailedException: Tests unsuccessful
[error] Total time: 8 s, completed Sep 29, 2016 2:26:52 PM

我觉得问题在于使用akka+spec2。 scalaetest和pact jvm的类似示例也适用