【发布时间】:2019-11-19 14:08:03
【问题描述】:
我使用 pact 和 spring 进行 CDC 提供程序测试,我能够生成 pact 文件, 但是当我使用 pact json 进行提供程序测试时,出现以下错误:“没有找到匹配方法 runTest 的测试”,这是我的代码:
@RunWith(SpringRestPactRunner.class)
@Provider("myProvider")
@PactFolder("target/pacts")
@WebMvcTest(MyController.class)
public class ProviderTest {
@InjectMocks
private MyController myController; # the controller I want to test
@MockBean
private MyService myService; # the dependency of controller
@TestTarget
public final Target target = new SpringBootHttpTarget();
@State("my_state")
public void runTest() {
}
}
契约文件是这样的:
... other parts
"providerStates": [
{
"name": "my_state"
}
]
... other parts
我的测试似乎找不到“my_state”?
编辑: 这是我的演示项目,请帮忙看看,谢谢! https://github.com/wuhuanxing/pact_demo
【问题讨论】:
-
运行整个类,而不是单个方法。
标签: spring-test pact pact-jvm