【问题标题】:"No tests found matching Method " error on CDC test with spring and pact使用 spring 和 pact 进行 CDC 测试时出现“未找到匹配方法的测试”错误
【发布时间】: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


【解决方案1】:

该协议使用的是协议规范的第 3 版。确保您使用的是最新版本的 pact jar 以确保它支持版本 3。如果您可以在 Github 存储库中创建可重现的示例,您可以在 slack.pact.io 上寻求帮助。

【讨论】:

  • 我用的是pact的v3,我只是添加了demo项目,你可以看看,tanks
猜你喜欢
  • 2019-07-09
  • 2018-12-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-01-12
  • 2022-07-26
相关资源
最近更新 更多