How to integrate pact-jvm provider only with json file

218 Views Asked by At

I want to test my spring-boot Rest API by using a pact json file provided. The thing is all the resources on internet points to verifying using pact-broker. I will get there but currently, working on a POC for this is turning out to be quite difficult.

No matter what pom configuration, it tries to connect to localhost.

Here's my pom.xml

        <plugin>
        <groupId>au.com.dius.pact.provider</groupId>
        <artifactId>maven</artifactId>
        <version>4.1.11</version>
            <configuration>
            <serviceProviders>
                <serviceProvider>
                    <name>Service</name>
                    <consumers>
                        <consumer>
                            <name>consumer123</name>
                            <pactSource>/Usr/Pact-JVM-Example/pacts/</pactSource>
                        </consumer>
                    </consumers>
                </serviceProvider>
            </serviceProviders>
            <pactBrokerUrl/>
        </configuration>
    </plugin>

Please note that the json is physically residing on the provided path /Usr/Pact-JVM-Example/pacts/. Also, I've intentionally removed pactBrokerUrl as I am not planning to connect to a remote pact json.

In the end, I want the test to pass/fail on the basis of the json file in /Usr/Pact-JVM-Example/pacts/ when I run ./mvnw pact:verify

1

There are 1 best solutions below

0
On

Please check the main readme here https://github.com/pact-foundation/pact-jvm/tree/master/provider/maven

This plugin is for verifying a running provider

It always tries to call a localhost server by default. You need Junit4 or Junit5 libraries