3
votes

Is there a small and concise jvm consumer Java (consumer or provider) junit project that somebody could share, preferably in a self contained zip file with all files contained, except for the jar imports?

When I follow for example the steps here: https://github.com/DiUS/pact-jvm/tree/master/pact-jvm-consumer-junit and "Using the base ConsumerPactTest" I get various errors, that I have tried to resolve one by one.

However I believe there must exist a simpler "Hello world" type of example to depict this framework.

I have setup other microservice mocking frameworks before, but Pact shows too many errors setting it up, so I think must have misunderstood how this is supposed to be setup, in its simplest form.

The last issues I had with the example aforementioned were these imports that I find no jar files for: import au.com.dius.pact.consumer.exampleclients.ConsumerClient; import au.com.dius.pact.consumer.ConsumerPactTest; import au.com.dius.pact.model.PactFragment;

For this reason for example @Pact keyword cannot be resolved etc.

Thanks in advance!


Update - Is it possible to NOT use the pact provider mock server code, and instead use the "real" api provider , when creating the pact definition(using ./gradlew test )?

For example in the example at 1), would it be possible to just update (for example using a recorded response in postman) the consumer's @Pact section with the "real" api provider response, without the need to created a mocked response in the spring boot localhost mock server?

1) http://the-creative-tester.github.io/Java-Consumer-Driven-Contract-Testing/

Thank you for any answers!

3
I've written these two articles on pact if they can be helpful somehow: hmh.engineering/… and hmh.engineering/pact-with-java-by-example-bb7175f62d58 - Francislainy Campos

3 Answers

3
votes

went through a few tutorial for pact for java. found out https://github.com/Mikuu/Pact-JVM-Example#pact-jvm-example has the best coverage/explanation. Including the interaction to pack broker, changing state for pact testing and it is very easy to follow. I really appreciate the effort from the originator for such wonderful documents

2
votes

I recently created the PACT-JVM project using Java and Gradle.

https://github.com/contactsai123/PACT-JVM-Example

It has 1 provider / 2 consumers and setup is pretty straight forward to understand.