Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
JUnit5 provider test with broker integration
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@Provider("UserServiceJUnit5")
@PactBroker(url = "http://localhost:9292")
@SetSystemProperty(key = "pact.verifier.publishResults", value = "true")
public class PactProviderJUnit5WithBrokerTest {
@LocalServerPort
int port;
@BeforeEach
public void setup(PactVerificationContext context) {
context.setTarget(new HttpTestTarget("localhost", port));
}
@State("A running user service")
void setupUserService() {
// no state setup ATM
}
@TestTemplate
@ExtendWith(PactVerificationInvocationContextProvider.class)
void pactVerificationTestTemplate(PactVerificationContext context) {
context.verifyInteraction();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment