spring - 向协议代理发布验证结果在 pact-jvm-provider-spring_2.12 中不起作用
问题描述
我正在尝试使用 pact for jvm/spring 将验证结果发布给 pact broker。我正在使用junit4。测试执行并通过,验证报告打印到控制台/添加 json 文件,但它没有将结果发布到协议代理。
在 pom.xml 中:
<dependency>
<groupId>au.com.dius</groupId>
<artifactId>pact-jvm-provider-spring_2.12</artifactId>
<version>3.5.24</version>
</dependency>
在 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 中设置它才能让它工作:
void setupTestTarget(PactVerificationContext context) {
context.setTarget(new HttpTestTarget("localhost", port, "/"));
System.setProperty("pact.verifier.publishResults", "true");
System.setProperty("pact.provider.version", buildVersion);
}
推荐阅读
- javascript - 如何在颤振的 android 应用程序中嵌入 powerbi 报告?
- c++ - 代码在 Visual Studio 2019 中无法正常工作
- node.js - GraphQL 使用 nodejs 将 DB int 转换为 Enum 时出错
- php - PHP 致命错误:未捕获的 ArgumentCountError:功能参数太少
- intellij-idea - 在 IntelliJ 中使当前选项卡全屏显示
- arrays - 如何修复“在范围内找不到‘NSFetchRequest’错误
- r - NNETAR 预警信息预报
- autodesk-forge - Autodesk Forge 大型模型查看器 - 抑制的 Inventor 组件
- networking - Puppeteer 不能忽略网络接口
- java - 如何更改警报中单选按钮的文本颜色和色调颜色?