gpt4 book ai didi

gradle - Pact提供程序不会将验证发送给Pact Broker

转载 作者:行者123 更新时间:2023-12-03 03:26:50 29 4
gpt4 key购买 nike

我是Pact(消费者驱动的测试)的新手,并且使用gradle,我曾在这个著名的研讨会上尝试使用Java和Pact Brocker https://github.com/Mikuu/Pact-JVM-Example进行Pact,但是当提供程序将验证发送给Pact Broker时,最后的部分将永远失效。它可以通过REST API手动运行,但是使用该项目时永远不会发送验证。请帮助了解发生了什么(可能缺少某些内容,某些库或注释?)

当生产者尝试将验证发送到Pact Broker(使用gradle和./gradlew :example-provider:pactVerify的docker中的本地Broker)时,我会附加调试日志。我猜是缺少POST请求的正文。

14:22:59.469 [DEBUG] [org.apache.http.impl.execchain.MainClientExec] Opening connection {}->http://localhost:80
14:22:59.469 [DEBUG] [org.apache.http.impl.conn.DefaultHttpClientConnectionOperator] Connecting to localhost/127.0.0.1:80
14:22:59.470 [DEBUG] [org.apache.http.impl.conn.DefaultHttpClientConnectionOperator] Connection established 127.0.0.1:55770<->127.0.0.1:80
14:22:59.470 [DEBUG] [org.apache.http.impl.execchain.MainClientExec] Executing request POST /pacts/provider/ExampleProvider/consumer/JunitRuleMultipleInteractionsConsumer/pact-version/e66d465478e1934bca0ad9b905a2f83835af481d/verification-results HTTP/1.1
14:22:59.470 [DEBUG] [org.apache.http.impl.execchain.MainClientExec] Target auth state: UNCHALLENGED
14:22:59.470 [DEBUG] [org.apache.http.impl.execchain.MainClientExec] Proxy auth state: UNCHALLENGED
14:22:59.492 [DEBUG] [org.apache.http.impl.execchain.MainClientExec] Connection can be kept alive indefinitely
14:22:59.493 [DEBUG] [org.apache.http.impl.conn.DefaultManagedHttpClientConnection] http-outgoing-255: Close connection
14:22:59.493 [DEBUG] [org.apache.http.impl.execchain.MainClientExec] Connection discarded
14:22:59.493 [DEBUG] [org.apache.http.impl.conn.PoolingHttpClientConnectionManager] Connection released: [id: 255][route: {}->http://localhost:80][total kept alive: 0; route allocated: 0 of 5; total allocated: 0 of 10]
14:22:59.493 [DEBUG] [org.gradle.internal.progress.DefaultBuildOperationExecutor] Completing Build operation 'Execute verifyPact for :example-provider:pactVerify_ExampleProvider'
14:22:59.493 [DEBUG] [org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter] Removed task artifact state for {} from context.
14:22:59.493 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Finished executing task ':example-provider:pactVerify_ExampleProvider'
14:22:59.493 [DEBUG] [org.gradle.internal.progress.DefaultBuildOperationExecutor] Completing Build operation 'Task :example-provider:pactVerify_ExampleProvider'
14:22:59.493 [null] [org.gradle.internal.progress.DefaultBuildOperationExecutor]
14:22:59.493 [DEBUG] [org.gradle.internal.progress.DefaultBuildOperationExecutor] Build operation 'Task :example-provider:pactVerify_ExampleProvider' completed
14:22:59.493 [INFO] [org.gradle.execution.taskgraph.DefaultTaskPlanExecutor] :example-provider:pactVerify_ExampleProvider (Thread[Task worker for ':',5,main]) completed. Took 0.96 secs.

最佳答案

pact示例似乎缺少了一个重要步骤:添加@PactBroker批注

在@Pact注释下方,应该有一个注释

@PactBroker(port = PORT_NUM , host = HOST_NAME)

您可以在这里找到一个示例 at the official repo

关于gradle - Pact提供程序不会将验证发送给Pact Broker,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50774009/

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