Quarkus Pact Provider

This extension ensures Pact provider libraries works well with Quarkus applications, including with continuous testing. It is based on version 4.3.17 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.


Note the provided scope, rather than test or default. This is needed for the tests to pass in continuous testing mode.

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

  • If continuous testing is being used, the dependency scope cannot be test. The provided scope is a good alternative.ps

  • @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)

  • A harmless java.lang.NoClassDefFoundError: org/apache/hc/client5/http/fluent/Request message will be produced if Pact tracking is enabled (GitHub issue)

Samples and resources