0

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

4

1 回答 1

0

That pact is using version 3 of the pact specification. Make sure you're using the latest version of the pact jar to ensure it supports version 3. If you can create a reproducible example in a Github repository, you can ask for help on slack.pact.io.

于 2019-11-18T00:12:19.663 回答