Bi-Directional Contract Testing Workshop

Level: Intermediate

Learn how to implement a Bi-Directional Contract Testing workflow from end-to-end, including integration with your CI/CD system.

Workshop Prerequisites

You must have:

Goals

You will learn how:

  1. To use OpenAPI as part of a contract testing strategy

  2. API testing tools such as Dredd or Postman can be used with API Hub for Contract Testing

  3. To publish contracts (such as a pact file or an OpenAPI document) to API Hub for Contract Testing

  4. To prevent deploying breaking changes to an environment, such as production

  5. To use existing mocking tools (such as Mountebank or Wiremock) to create a consumer contract

Ways of completing the workshop

  1. See our online katacoda tutorials. The specific bi-directional course that covers the below agenda can be found here.

    • Note

      To complete the workshop, you will need to authenticate to Killercoda (the online learning platform) with GitHub, Google, Twitter or LinkedIn.

  2. You can pick and choose a bi-directional consumer/provider example from our exhaustive list, and you will start by forking the repositories into your own Github account, setting up Github Actions as CI builds, and configuring the projects to point to your own API Hub for Contract Testing account. Don't worry, we will take you step by step in the workshop.API Hub for Contract Testing Code Demos

Agenda

You will:

  1. Create and document an API using OpenAPI Specification

  2. Write tests for the API using an API testing tool such as RestAssured, Dredd, Postman ,and Schemathesis/SwashbuckleExample Java Provider - RestAssuredExample NodeJS Provider - DreddExample NodeJS Provider - PostmanExample .NET Provider - Schemathesis

  3. Publish the provider contract (an OpenAPI document) to API Hub for Contract Testing

  4. Deploy the provider to production

  5. Write the API consumer

  6. Write tests for an API client using tools such as Mountebank, Nock, Wiremock, Nock, Cypress, and Mock-Service-Worker or traditional Pact .NET to mock the API, and convert those mocks into a consumer contractExample NodeJS Consumer - Mountebank (BYO Adapter)Example NodeJS/React Consumer - Nock (BYO Adapter)Example Java Consumer - Wiremock (BYO Adapter)Example NodeJS/React Consumer - Nock (BYO Adapter)Example NodeJS/React Consumer - Cypress (BYO Adapter)Example NodeJS/React Consumer - Mock Service Worker (BYO Adapter)Example .NET Consumer - Pact-Net

  7. Publish the consumer contract to API Hub for Contract Testing

  8. Deploy the consumer to production

  9. Learn about API Hub for Contract Testing's breaking change detection system

Tools used

Publication date: