The previous post explains the principles and motivations behind contract testing. Today we give a look to how write consumer-driven contract tests with pact and Java in a SpringBoot application.
Pact foundation provides junit5 integration for creation and verification of contracts.
Let’s start!
What you need The Java Pact Testing framework used in this example is the 4.0.0, based on v3 specification.
Furthermore, you should have:
jdk 1.8 or later maven 3.
Introduction This is the first of a series of blog posts about Contract Testing which cover the minimum set of theory and practice necessary for an effective adoption in your team, from design to code integration.
Contract Testing is a category of testing activity where the data formats and conventions defined by two systems (services) which communicate a business value, is tested against a Mock called “Contract”. A service provides a callable API that can be consumed by another (or many) service which create an interaction between parties that needs to be satisfied during the evolution and developing of services which are now coupled.