The consumer project owns and generates the Pact contract file.
To run the pact-tests, do the following (assuming you’ve checked out the project and are in the example directory):
cd consumer sbt pact-test
You should now be able to see a file in the
consumer/target/pacts/ directory called
Consumer_Provider.json. This is your Pact file that describes the behaviour you expect fro the Provider service.
If you wanted to, you could now run a stub version of the Provider service, again from the
consumer directory, by simply entering
sbt pact-stubber on the command line and the service would start on port
Try it, you should be able to go hit the results end point in your browser.
You could also use the standalone stubber. If you plan to use this in a CI pipeline you should consider assembling it into a JAR by running
In a real scenario, you would probably use Pact Broker to send the newly created Pact contract to the Provider ahead of verification.
Instead we’re going to use a script to do the delivery. Navigate back to the main example directory on the terminal and run:
This script simply copies the
Consumer_Provider.json file into the