我使用 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