pact-jvm
pact-jvm copied to clipboard
Contract test example for message queue in clojure
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.
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:
-
Write your clojure tests as JUnit tests using annotations (I assume you can do this).
-
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. -
Write the test support method in Clojure.
Hi @uglyog - I prefer the second option. Do you think you can accommodate this in near future? Thank in advance.
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
Can you write you Clojure test now? If you could contribute an example test for the project, it would be helpful for other people.