pact-jvm icon indicating copy to clipboard operation
pact-jvm copied to clipboard

Contract test example for message queue in clojure

Open neharastogi093 opened this issue 4 years ago • 7 comments

Could you please point me to some example for writing message queue pact tests. If clojure examples are not possible then java example will also work.

I am having trouble finding equivalent of ConsumerPactRunner/runConsumerTest which excepts the MessagePact instead of RequestResponsePact.

Example for both consumer and producer would help.

neharastogi093 avatar May 25 '20 07:05 neharastogi093

Oh, wow! Clojure still around! :-D

There are no examples that I know of. In fact, this is the first time I've heard of someone trying to do message queue Pact tests with Clojure.

The main issue with message queue tests is they invoke a method to either generate the message (on the provider side) or process the message (on the consumer side). The JUnit examples use annotated methods for this.

So there are a few options:

  1. Write your clojure tests as JUnit tests using annotations (I assume you can do this).

  2. Create a test that is similar to https://github.com/DiUS/pact-jvm/blob/master/consumer/junit/src/test/clojure/au/com/dius/pact/consumer/junit/example_clojure_consumer_pact_test.clj, which would need a support method similar to ConsumerPactRunnerKt/runConsumerTest but that deals with messages. No mock server will be started.

  3. Write the test support method in Clojure.

uglyog avatar May 25 '20 23:05 uglyog

Hi @uglyog - I prefer the second option. Do you think you can accommodate this in near future? Thank in advance.

neharastogi093 avatar May 28 '20 11:05 neharastogi093

Hi @uglyog I've attempted to implement the required helper method (your suggested option 2), which could be used by a Clojure test to run a test and write the json file. Happy about any feedback! Pull request

chrisport avatar Jun 02 '20 09:06 chrisport

Can you write you Clojure test now? If you could contribute an example test for the project, it would be helpful for other people.

uglyog avatar Jun 12 '20 00:06 uglyog