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:
-
A Swagger account with an active Swagger Contract Testing subscription
-
obtained a read/write API Token from your Contract Testing account
-
a basic understanding of APIs, unit testing, and how to operate a Linux terminal
Goals
You will learn how:
-
To use OpenAPI as part of a contract testing strategy
-
API testing tools such as Dredd or Postman can be used with Contract Testing
-
To publish contracts (such as a pact file or an OpenAPI document) to Contract Testing
-
To prevent deploying breaking changes to an environment, such as production
-
To use existing mocking tools (such as Mountebank or Wiremock) to create a consumer contract
Ways of completing the workshop
-
See our online katacoda tutorials. The specific bi-directional course that covers the below agenda can be found here.
-
To complete the workshop, you will need to authenticate to Killercoda (the online learning platform) with GitHub, Google, Twitter or LinkedIn.
-
-
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 Contract Testing account. Don’t worry, we will take you step by step in the workshop.
Agenda
You will:
-
Create and document an API using OpenAPI Specification
-
Write tests for the API using an API testing tool such as RestAssured, Dredd, Postman, and Schemathesis/Swashbuckle. Visit the Examples page for more information.
-
Publish the provider contract (an OpenAPI document) to Contract Testing
-
Deploy the provider to production
-
Write the API consumer
-
Write tests for an API client using tools such as Mountebank, Nock, Wiremock, Cypress, and Mock-Service-Worker or traditional Pact .NET to mock the API, and convert those mocks into a consumer contract. Visit the Examples page for more information.
-
Publish the consumer contract to Contract Testing
-
Deploy the consumer to production
-
Learn about Contract Testing’s breaking change detection system
Tools used
-
Node / Java or .NET - for the applications being tested
-
OpenAPI - for API Documentation
-
Mountebank - for API mocking
-
Wiremock - for API mocking
-
Nock - for API mocking
-
Cypress - for API mocking
-
Mock-Service-Worker - for API mocking
-
Dredd - for API Testing
-
Postman - for API Testing
-
RestAssured - for API Testing
-
Swashbuckle - for API Testing
-
Schemathesis - for API Testing
-
Github Actions - for CI/CD pipeline