The test automation pyramid suggests that we should favour unit and integration tests over end-to-end tests, which leads developers to use test doubles (fakes, stubs, mocks etc.). The risk is that the developer’s test double does not behave in exactly the same way as the actual component that it is replacing. When this happens, the tests all pass in your build pipeline, but you get failures when it’s released into an integration (or production) environment.
Contract testing is a technique that can give you confidence that your test doubles are accurately simulating the dependencies that they replace. This is not a new technique, but the extra investment in creating and maintaining (yet another) suite of tests has restricted its uptake. Instead, organizations mitigate the risks by investing in more and more integration environments and end-to-end tests. This was always expensive, but with the adoption of micro-service architectures across the industry, the cost and complexity has escalated to a point where this approach is no longer sustainable.
There is now an urgent need for organizations to revisit contract testing, with a specific focus on consumer driven contracts for micro-services. This need led to the creation of the Pact open source tool for HTTP based micro-services. The Pact project has created a multi-platform suite of tools that dramatically simplifies the adoption of contract testing.
In this session, you’ll learn why contract testing is critically important, look at how you can incorporate contract testing in your development practices, and get an introduction to Pact.