I write cdc provider tests with pact provider.
@PactBroker(url = "https://pact.h.com")
@ExtendWith(PactVerificationInvocationContextProvider.class)
public class ProviderContractEventsTest {
public ObjectMapper mapper = new ObjectMapper();
public JFixture fixture = new JFixture();
@ExtendWith(PactVerificationInvocationContextProvider.class)
void pactVerificationTestTemplate(PactVerificationContext context) {
context.verifyInteraction();
public void before(PactVerificationContext context) {
fixture.customise().repeatCount(1);
context.setTarget(new MessageTestTarget());
public String d() throws JsonProcessingException {
var domain = fixture.create(GMessage.class);
domain.setItems(Collections.singletonList(fixture.create(GMessage.class)));
return mapper.writeValueAsString(domain);
public String e() throws JsonProcessingException {
var domain = fixture.create(FMessage.class);
return mapper.writeValueAsString(domain);
<code>@Provider("i-api")
@PactBroker(url = "https://pact.h.com")
@ExtendWith(PactVerificationInvocationContextProvider.class)
public class ProviderContractEventsTest {
public ObjectMapper mapper = new ObjectMapper();
public JFixture fixture = new JFixture();
@TestTemplate
@ExtendWith(PactVerificationInvocationContextProvider.class)
void pactVerificationTestTemplate(PactVerificationContext context) {
context.verifyInteraction();
}
@BeforeEach
public void before(PactVerificationContext context) {
fixture.customise().repeatCount(1);
context.setTarget(new MessageTestTarget());
}
@State("x")
@PactVerifyProvider("y")
public String d() throws JsonProcessingException {
var domain = fixture.create(GMessage.class);
domain.setItems(Collections.singletonList(fixture.create(GMessage.class)));
return mapper.writeValueAsString(domain);
}
@State("z")
@PactVerifyProvider("t")
public String e() throws JsonProcessingException {
var domain = fixture.create(FMessage.class);
return mapper.writeValueAsString(domain);
}
}
</code>
@Provider("i-api")
@PactBroker(url = "https://pact.h.com")
@ExtendWith(PactVerificationInvocationContextProvider.class)
public class ProviderContractEventsTest {
public ObjectMapper mapper = new ObjectMapper();
public JFixture fixture = new JFixture();
@TestTemplate
@ExtendWith(PactVerificationInvocationContextProvider.class)
void pactVerificationTestTemplate(PactVerificationContext context) {
context.verifyInteraction();
}
@BeforeEach
public void before(PactVerificationContext context) {
fixture.customise().repeatCount(1);
context.setTarget(new MessageTestTarget());
}
@State("x")
@PactVerifyProvider("y")
public String d() throws JsonProcessingException {
var domain = fixture.create(GMessage.class);
domain.setItems(Collections.singletonList(fixture.create(GMessage.class)));
return mapper.writeValueAsString(domain);
}
@State("z")
@PactVerifyProvider("t")
public String e() throws JsonProcessingException {
var domain = fixture.create(FMessage.class);
return mapper.writeValueAsString(domain);
}
}
I run the tests with below terminal code:
mvn clean test -Dtest=”com.c.t.contract.tests.**”
I want to verify all states together as my provider test counts almost 90 and it increases pipeline time. How to do it ?