pact-jvm Consumer Pact Test

1.8k Views Asked by At

I'm new to pact. My project is Java project. I read through pact documentation and found the github project https://github.com/DiUS/pact-jvm/tree/master/pact-jvm-consumer-junit I imported it in my eclipse IDE. I'm stuck from here. 1. Which test to run first. ExampleJavaConsumerPactRuleTest or ExampleJavaConsumerPactTest? 2. I see that it is a gradle build. How to configure the run configurations. What are the arguments and commands to provide?

2

There are 2 best solutions below

0
On

The question here is how do you want to go about it. Its Consumer driven. So you should first make the Consumer test so that you have a pact file so you can use that in your provider test.

A good start is reading this on the pact website: https://docs.pact.io Hope this helps

0
On

The PACT starts with the consumers that say what they expect from the provider. Then, later, the provider needs to be checked if it fits into the pacts defined by every consumer.

So, the first thing to do it is to create the consumer that act like the provider exists, defining what it is expected from that provider.

I just created one consumer example, https://github.com/thiagomata/helloword-pact-consume that is ready to go. As I said before, you can run that consumer and define the pact without the existence of the provider.

The library that I am using runs and update the pact with the JUnit tests. I hope that helps.