Reputation: 1
I have created a REST-service with spring. Now I want to use pact and junit 5 to test the consumer-provider-communication. I have already a running pact-broker (from https://github.com/jaimeniswonger/pact-broker-openshift). The consumer-test works fine and publishes the pacts. The provider-test loads these and trys to verificat them. But the test uploads the results only if the verification is succesfull. I tried running the test with surefire and failsafe.
The code for the test:
@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() {
}
}
The pact broker properties are defined in the 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>
Is it possible to configure the test to notify the pact-broker that a verification failed?
Upvotes: 0
Views: 2430
Reputation: 1318
This seems to be a defect. Can you please raise it in the https://github.com/dius/pact-jvm repository?
Upvotes: 0