Quarkus Pact Provider

This extension ensures Pact provider libraries works well with Quarkus applications, including with continuous testing. It is based on version 4.6.10 of the Pact JVM JUnit 5 library.


To use this extension, add the io.quarkiverse:quarkus-pact-provider extension first to your build file. Choose a 1.x version for Quarkus 3, and a 0.x version for Quarkus 2.


Example usage

Use Pact as you normally would. For example, a simple provider test for REST endpoints would look like this:

@Provider("Farm") (1)
public class SimpleContractTest {

    @ConfigProperty(name = "quarkus.http.test-port")
    int quarkusPort;

    void before(PactVerificationContext context) {
        context.setTarget(new HttpTestTarget("localhost", quarkusPort)); (3)

    @TestTemplate (4)
    void pactVerificationTestTemplate(PactVerificationContext context) {
1 Add @Provider annotations to the class, along with instructions where to find the pacts (a folder or a broker).
2 We inject Quarkus configuration.
3 With the injected configuration, we can tell the Pact verifier where to look for our endpoints.
4 Standard Pact provider boilerplate, to create a series of templated tests which run the Pact verifications.

Extension Configuration Reference

For the moment, Pact needs to be configured by the normal Pact system properties.

Known limitations

  • @State methods do not not have access to the CDI context (GitHub issue)

  • When changing the code of classes with a @TestTemplate, continuous testing may not automatically retrigger (Fix PR)

  • @TestProfile does not work in dev mode (GitHub issue)

Samples and resources