Skip to content

Instantly share code, notes, and snippets.

@dnno
Last active January 2, 2023 13:22
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save dnno/3ce96e517a812e0f9c6c92c2f85a258c to your computer and use it in GitHub Desktop.
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