如何使用@PactTestFor 定义多个提供者

How to define multiple providers using @PactTestFor

我们正在使用 PACT 库进行合同测试。当前项目依赖于 junit5 集成。我必须扩展一项测试以使用 2 个提供商而不是 1 个:

当前版本:

    @Test
    @PactTestFor(providerName = "request-repository", hostInterface = "0.0.0.0", port = "9991")
    public void myTestMethod() throws Exception {}

我阅读了文档:https://docs.pact.io/implementation_guides/jvm/consumer/junit5 似乎还不支持它:

Unsupported#

The current implementation does not support tests with multiple providers. This will be added in a later release.

我查看了发行说明,但没有发现任何更新。还有另一种定义另一个提供者的方法吗?即:

    @Test
    @PactTestFor(providerName = "request-repository", hostInterface = "0.0.0.0", port = "9991")
    @PactTestFor(providerName = "result-repository", hostInterface = "0.0.0.0", port = "9992")
    public void myTestMethod() throws Exception {}

或者在这种情况下,junit5 集成不是一个好的选择?

我的建议是编写 2 个单独的测试,其中每个测试都有一个通过 Pact 模拟的提供者,另一个提供者被删除(例如,使用标准单元测试存根)。