liveBook · Manning

What you will learn in Contract Testing in Action

With Pact, PactFlow, and GitHub Actions

by Marie Cruz and Lewis Prescott
Foreword by Mark Winteringham

Chapter by chapter

Chapter 1: Introduction to contract testing

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 · 1.6 Summary

What you learn in chapter 1 →

Chapter 2: How contract testing fits into wider testing concepts

2.1 Contract testing and other testing types · 2.1.1 Unit testing · 2.1.2 Integration testing · 2.1.3 End-to-end testing · 2.1.4 The ice cream cone of test automation · 2.1.5 Contract testing in the test automation pyramid · 2.2 Does contract testing replace other types of tests? · 2.3 Benefits of contract testing · 2.3.1 Cost saving benefits · 2.3.2 Quality benefits · 2.3.3 Team benefits · 2.4 Introducing contract testing to your teams · 2.4.1 Start with Why · 2.4.2 Start small and incrementally · 2.4.3 Communicate benefits and progress visibly · 2.4.4 Find allies or champions · 2.5 Challenges with contract testing · 2.5.1 Contract testing takes time · 2.5.2 Contract testing requires a mindset shift · 2.5.3 Lack of buy-in · 2.5.4 More technical than other testing activities · 2.5.5 Difficult when there are external teams · 2.6 A practical guide on introducing contract testing to projects · 2.6.1 Research what tools to use · 2.6.2 Identify your consumers and providers · 2.6.3 Define the contract · 2.6.4 Write a basic consumer and provider contract test · 2.6.5 Add contract testing to your CI/CD pipelines · 2.7 Summary

What you learn in chapter 2 →

Chapter 3: A technical overview of contract testing

3.1 What is a consumer? · 3.2 What is a provider? · 3.3 What is a contract? · 3.4 What is a contract broker? · 3.5 Consumer-driven contract testing life cycle · 3.6 Contract testing tools · 3.6.1 Contract-based tools · 3.7 Contract Testing Approaches · 3.7.1 Consumer-driven contract testing · 3.7.2 Provider-driven contract testing · 3.8 Communication types supported by contract testing · 3.8.1 GraphQL · 3.8.2 Event-driven systems · 3.9 Summary

What you learn in chapter 3 →

Chapter 4: Implementing consumer-driven contract testing for web applications

4.1 Guidelines in writing consumer contract tests · 4.1.1 The focus of a consumer contract test · 4.1.2 The importance of using mocks instead of stubs · 4.1.3 Using loose matchers to avoid high coupling · 4.1.4 The importance of writing isolated contract tests · 4.1.5 Using can-i-deploy to verify that you can safely deploy to production · 4.2 Contract testing tooling setup for the consumer · 4.2.1 Requirements · 4.3 Consumer contract tests between a web application and data provider · 4.3.1 Movies API overview · 4.3.2 Web application overview · 4.3.3 Consumer contract · 4.3.4 Writing the first consumer contract test · 4.3.5 Other programming languages · 4.4 Publishing the contract to Pact Broker · 4.4.1 Committing all changes to GitHub · 4.5 Summary

What you learn in chapter 4 →

Chapter 5: Implementing consumer-driven contract testing for mobile clients

5.1 Pact consumer setup for Android apps · 5.1.1 Requirements · 5.1.2 Mobile app implementation · 5.2 Android consumer test implementation · 5.3 Android consumer contract generation · 5.3.1 Pact matchers · 5.3.2 Pact POST requests · 5.4 Chapter exercise · 5.5 Summary

What you learn in chapter 5 →

Chapter 6: Implementing consumer-driven provider contract tests

6.1 Guidelines in writing provider contract tests · 6.1.1 The focus of a provider contract test · 6.1.2 Using provider states effectively · 6.1.3 Using can-i-deploy to verify that you can safely deploy to production · 6.2 Contract testing tooling setup for the provider · 6.3 Provider contract tests between a web application and data provider · 6.3.1 Writing the provider test · 6.3.2 Introducing provider states · 6.4 Provider contract tests between a mobile app and data provider · 6.5 Chapter exercise · 6.6 Summary

What you learn in chapter 6 →

Chapter 7: Contract testing for GraphQL

7.1 A brief introduction to GraphQL · 7.2 GraphQL application overview · 7.2.1 GraphQL server overview · 7.2.2 Running the GraphQL server · 7.2.3 Consumer overview · 7.3 Consumer contract tests between a consumer and GraphQL layer · 7.3.1 Importing the required dependencies · 7.3.2 Setting up the mock provider · 7.3.3 Registering the consumer expectation · 7.3.4 Verifying the consumer test and generating the contract · 7.3.5 Publishing the contract to Pact Broker · 7.4 Provider contract tests between a consumer and GraphQL layer · 7.5 Chapter exercise · 7.6 Summary

What you learn in chapter 7 →

Chapter 8: Contract testing for event-driven architecture

8.1 Introduction to asynchronous API testing · 8.2 Pact consumer message setup with Kafka · 8.2.1 Requirements · 8.3 Kafka consumer implementation · 8.4 Event handler consumer test implementation · 8.5 Event consumer contract generation · 8.6 Kafka producer implementation · 8.7 Event producer test implementation · 8.8 Summary

What you learn in chapter 8 →

Chapter 9: Storing, hosting, and securing the contracts

9.1 Why we need Pact Broker · 9.1.1 Pact Broker core features · 9.2 Pact Broker options · 9.3 SaaS Pact Broker (PactFlow) · 9.3.1 Setting up PactFlow · 9.3.2 PactFlow API token · 9.3.3 PactFlow user management · 9.3.4 Other PactFlow features · 9.4 Self-hosted Pact Broker · 9.4.1 Pact Broker with Docker · 9.4.2 Kubernetes Pact Broker · 9.5 SaaS vs. self-hosted Pact Broker · 9.6 Summary

What you learn in chapter 9 →

Chapter 10: Setting up contract testing in a CI/CD pipeline

10.1 Basic CI/CD setup for the consumer and provider · 10.1.1 Setting up GitHub Actions · 10.1.2 Example configuration for other CI/CD platforms · 10.2 Advanced features to improve the CI/CD setup · 10.2.1 Configuring consumer and provider versions · 10.2.2 Configuring branches · 10.2.3 Creating environments · 10.2.4 Recording deployments and/or releases · 10.2.5 Using the can-i-deploy tool · 10.3 Chapter exercises · 10.4 Webhooks · 10.4.1 Creating the Pact webhook · 10.4.2 Creating a different GitHub workflow for provider verification · 10.4.3 Updating provider options · 10.4.4 Retries for can-i-deploy · 10.4.5 Testing the webhook · 10.5 Summary

What you learn in chapter 10 →

Chapter 11: Implementing provider-driven contract testing

11.1 Introduction to provider-driven contract testing · 11.1.1 Why was PDCT introduced? · 11.1.2 How PDCT addresses the drawbacks of CDCT · 11.1.3 Drawbacks with PDCT · 11.2 Implementing consumer test adapters · 11.2.1 Cypress consumer adapter · 11.2.2 WireMock consumer adapter · 11.2.3 Publish consumer contracts · 11.3 Implementing provider tests with API testing tools · 11.3.1 Postman and OpenAPI example · 11.3.2 Dredd and OpenAPI example · 11.3.3 Publish provider API specification and test results · 11.3.4 Checking consumer contracts · 11.4 Summary

What you learn in chapter 11 →

Chapter 12: Moving integration tests to contract tests

12.1 When to use integration tests over contract tests · 12.2 Identifying suitable integration tests to migrate · 12.3 Refactoring integration tests to contract tests · 12.4 Refactoring end-to-end tests to contract tests · 12.5 Summary

What you learn in chapter 12 →

Concepts explained in this book

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.