visit
recently crossed on GitHub and has been very , even beginning to feature in as a desired skill. Not bad, given this project is just ten months old !
Karate’s innovative “mis-use” of Gherkin has worked out extremely well in practice, and actually happens to be a great fit even when “inverting” things to work on the server-side. Here’s an example that showcases how simple it is to write a stateful test-double for a REST service. Things just click into place, like Karate’s native support for JSON and XML, and the power of the shines through.
the actual source for this example: You can find a comprehensive list of capabilities in the . While the README evolves, a demo end-to-end example using has been created as an early preview for the community, and is summarized below.
We use a simplified example of a Java ‘consumer’ which makes HTTP calls to a Payment Service (provider) where GET
, POST
, PUT
and DELETE
have been implemented. The 'provider' implements CRUD for the [Payment.java](//github.com/intuit/karate/blob/develop/karate-demo/src/test/java/mock/contract/Payment.java)
'POJO', and the POST
(or create) results in a message ([Shipment.java](//github.com/intuit/karate/blob/develop/karate-demo/src/test/java/mock/contract/Shipment.java)
as JSON) being placed on a queue, which the consumer is listening to.
is being used for the sake of mixing an asynchronous flow into this example, and with the help of some , we are able to mix asynchronous messaging into a Karate test as well as the test-double.
Karate on the ‘other side of the fence’ (handling HTTP requests instead of making them) — turns out to be remarkably effective, yet simple.
If you think about it, all the above are sufficient to implement any micro-service. Karate’s DSL syntax is focused on exactly these aspects, thus opening up interesting possibilities.
It may be hard to believe that you can spin-up a ‘usable’ micro-service in minutes with — but do try it and let me know what you think !