gpt4 book ai didi

java - pact-jvm-consumer-specs2 - 缺少 : [error] method: GET

转载 作者:太空宇宙 更新时间:2023-11-04 12:12:10 25 4
gpt4 key购买 nike

对于使用 sbt 运行的 spec2 消费者,我的 Pact JVM 存在问题。- 可能出什么问题了?- 我没有生成任何契约文件。

给定:

  • 具有依赖项的 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 test 时,我得到:

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 的类似示例也有效。

关于java - pact-jvm-consumer-specs2 - 缺少 : [error] method: GET,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39770094/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com