【问题标题】:Pact does not send provider-verification result to pact broker if junit 5 test fails如果 junit 5 测试失败,Pact 不会将提供者验证结果发送给 pact 代理
【发布时间】:2018-09-06 13:21:42
【问题描述】:

我用 spring 创建了一个 REST 服务。现在我想使用 pact 和 junit 5 来​​测试消费者-提供者-通信。我已经有一个正在运行的契约经纪人(来自https://github.com/jaimeniswonger/pact-broker-openshift)。消费者测试工作正常并发布协议。 provider-test 加载这些并尝试验证它们。但测试只有在验证成功的情况下才会上传结果。我尝试使用surefire和failsafe运行测试。

测试代码:

@ExtendWith(SpringExtension.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT, properties = "server.port=12223")
@Provider("Provider")
@PactBroker
public class ProviderPactTest {

    @BeforeEach
    void setupTestTarget(PactVerificationContext context) {
        context.setTarget((new HttpsTestTarget("localhost", 12223, "/", true)));
    }

    @TestTemplate
    @ExtendWith(PactVerificationInvocationContextProvider.class)
    void pactVerificationTestTemplate(PactVerificationContext context) {
        context.verifyInteraction();
    }

    @State({ "state1" })
    public void doNothing() {

    }
}

pact broker 属性在 pom 中定义:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>${maven.surefire.plugin.version}</version>
    <configuration>
        <systemPropertyVariables>
            <pact.provider.version>${project.version}</pact.provider.version>
            <pact.verifier.publishResults>true</pact.verifier.publishResults>
            <pact.verification.reports>json</pact.verification.reports>
            <pactbroker.tags>TAG</pactbroker.tags>
            <pactbroker.host>pact-broker.url.com</pactbroker.host>
            <pactbroker.port>80</pactbroker.port>
        </systemPropertyVariables>
    </configuration>
    <dependencies>
        <dependency>
            <groupId>org.junit.platform</groupId>
            <artifactId>junit-platform-surefire-provider</artifactId>
            <version>${junit-platform.version}</version>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <version>${junit.version}</version>
        </dependency>
    </dependencies>
</plugin>

是否可以配置测试以通知 pact-broker 验证失败?

【问题讨论】:

    标签: java pact pact-jvm pact-java pact-broker


    【解决方案1】:

    这似乎是一个缺陷。能否请您在https://github.com/dius/pact-jvm 存储库中提出它?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多