Chapter 6. Contract tests

 

This chapter covers

  • Understanding and writing contract tests
  • Using consumer-driven contracts
  • Working with Pact JVM
  • Integrating with Arquillian

So far in this book, you’ve learned about unit, component, and integration tests. One thing they have in common is that they don’t test the entire application, but rather isolated parts of it. With unit tests, the unit under test consists of only one or a few classes; with integration tests, you test whether boundaries can connect to a real service. This is the first chapter in which you’ll write tests to understand the application as a whole. In this chapter, you’ll learn why it’s important to use contract tests to verify the entire system, and how to write them.

6.1. Understanding contracts

The microservices architecture involves a lot of intercommunication between microservices. In this book’s Gamer example, you saw interactions between the aggregator service, the video service, the comments service, and so on. These interactions effectively form a contract between the services: this contract consists of expectations of input and output data as well as pre- and post-conditions.

6.2. Tools

6.3. Build-script modifications

6.4. Writing consumer-driven contracts for the Gamer application

6.5. Contract type summary

Exercise

Summary

sitemap