Implement PACT verification at one of two levels
What I learned today — 4 April 2018
When implementing the verification of a pact on the producer side one has to make a decision about how much of the producer to cover. One option is to test the producer end to end. The other option is to only test at the Rest controller’s level and to mock all interactions with other parts of the system.
The first option may be more realistic, but has the drawback that it will require more test scaffolding as well as maintenance. The second option limits the verification strictly to the API and may not check subtle differences in the data returned, but is much simpler to implement and maintain.
We decided to only verify the API, rather than actual data returned, and used Spring’s MockMvc to isolate our Rest controller. We already have acceptance tests, written using cucumber, that test the entire stack, therefore we decided that verifying pacts only at the API layer is pragmatic, even if small differences in data may slip through.