向pact broker发布验证结果在pact-jvm-provider-spring_2.12中不起作用 [英] Publish verification results to pact broker is not working in pact-jvm-provider-spring_2.12

查看:36
本文介绍了向pact broker发布验证结果在pact-jvm-provider-spring_2.12中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 jvm/spring 协议将验证结果发布到协议代理.我正在使用junit4.测试执行并通过,将验证报告打印到控制台/json 文件已添加,但不会将结果发布到协议代理.

I am trying to publish the verification results to pact broker with pact for jvm/spring. I am using junit4. The test is executed and passed, A verification report is printed to console/ json file is added, but it's not publishing the results to pact broker.

在 pom.xml 中:

In pom.xml:

<dependency>
    <groupId>au.com.dius</groupId>
    <artifactId>pact-jvm-provider-spring_2.12</artifactId>
    <version>3.5.24</version>
</dependency>

在 TestContract.class 中:

In TestContract.class:

@RunWith(SpringRestPactRunner.class)
@Provider("prov_test")
@PactBroker(host="192.168.132.220",port="80")
@VerificationReports({"console", "json"})
@SpringBootTest(
    properties={
        "pact.provider.version=1.0.1",
        "pact.verifier.publishResults=true"
    },
    webEnvironment = SpringBootTest.webEnvironment.DEFINED_PORT
)
public class TestContract {
...
...
}

在输出中我得到警告:

Skipping publishing of verification results (pact.verifier.publishResults is not set to 'true')

感谢您的帮助!

推荐答案

我们是 junit5,必须在 @BeforeEach 中设置它才能使其工作:

We're junit5 and had to set it in the @BeforeEach to get it to work :

    void setupTestTarget(PactVerificationContext context) {
        context.setTarget(new HttpTestTarget("localhost", port, "/"));
        System.setProperty("pact.verifier.publishResults", "true");
        System.setProperty("pact.provider.version", buildVersion);
    }

这篇关于向pact broker发布验证结果在pact-jvm-provider-spring_2.12中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆