This is a simplified version of the example in the Karate test-doubles documentation - with JMS / queues removed and simplified to be a stand-alone maven project.
Also see The World’s Smallest Microservice.
- clone the project
mvn clean test
You can click on the links to view the source-code. | File | Description | Comment | | —- | ———– | ——- | | PaymentService.java | Producer | A very simple Spring Boot app / REST service | | payment-contract.feature | Contract + Functional Test | Karate API test | | PaymentContractTest.java | Producer Integration Test | JUnit runner for the above | | payment-mock.feature | Mock / Stub | Karate mock that perfectly simulates the Producer ! | | PaymentContractAgainstMockTest.java | Verify that the Mock is as per Contract | JUnit runner that points
payment-mock.feature | | Consumer.java | Consumer | A simple Java app that calls the Producer to do some work | | ConsumerIntegrationTest.java | Consumer Integration Test | A JUnit full integration test, using the real Consumer and Producer | | ConsumerIntegrationAgainstMockTest.java | Consumer Integration Test but using the Mock | Like the above but using the mock Producer |