1 Introduction to contract testing

 

This chapter covers

  • What this book is about and why it’s important
  • A high-level overview of contract testing
  • Why you should care about contract testing
  • When contract testing is appropriate to use and not use
  • How contract testing works on a high level
  • Contract testing in action

Imagine this scenario. It’s 4 p.m. on a Friday, and you decided to deploy a small change of updating one of your API’s data responses. All the automated tests from your pipeline are returning green, which gives you the confidence that you haven’t broken anything. You hit deploy, and a few minutes after the deployment, you get a message from another team that something is broken in production. It couldn’t be the change you recently deployed because it was a small change, and all the tests are passin… . right? As it turns out, this other team using your API has certain expectations. During the incident, you’ve learned that these expectations are different from yours. Rather than enjoying your Friday afternoon, you’re left with a production bug you must deal with.

1.1 An overview of contract testing

1.2 Why contract testing matters

1.3 When is contract testing appropriate to use?

1.4 How contract testing works on a high level

1.4.1 Contract testing from the consumer side

1.4.2 Contract testing from the provider side

1.5 Contract testing in action

1.5.1 Example of a consumer contract test

1.5.2 Example of a provider contract test

Summary