Contract Testing using PACT with CODE Examples

preview_player
Показать описание
This video provides an in-depth look at contract testing and its application in API testing. We discuss the importance of contract testing in validating communications between services, such as a web frontend and a client API, and how it serves as a faster, more reliable alternative to traditional integration testing, which can often be expensive, slow, and flaky.

Key points covered in the video include:

- Why Use Contract Testing: Contract testing is essential for ensuring that two services, such as a consumer (e.g., web frontend) and a provider (e.g., client API), can communicate effectively. It helps to minimize flakiness and increase test reliability and speed.

- What is Contract Testing: Contract testing involves creating a contract between a consumer and provider, detailing the expected requests and responses. The presenter highlights the use of Pact, an open-source tool available in several languages, which facilitates the creation of these contracts.

- Benefits of Contract Testing: Contract testing offers quick, dependable testing solutions and addresses version control issues, making it easier to manage changes in request or response models.

- Implementing Contract Testing with Pact: The process starts with consumer tests where expected requests and responses are defined, and a mock provider is set up. This setup leads to the generation of a contract after verification passes. The video provides a step-by-step guide on setting up consumer tests, including defining interactions, running the mock provider, and verifying requests.

- Provider Tests: After consumer tests generate a contract, provider tests are conducted to validate the contract. Unlike consumer tests, provider tests don’t require a mock setup but use the generated contract to ensure the API can handle the expected requests correctly. The presenter walks through setting up provider tests, including specifying provider options, targeting the Pact broker URL, and publishing verification results.

- Pact Broker: A central component of the workflow where contracts are stored and shared between consumer and provider tests. It serves as a repository that holds all contracts and verification results, facilitating easy access and management of contracts across services.

#contracttesting #pact #javascript
Рекомендации по теме
Комментарии
Автор

Great video, I recommend that you fill the space you're talking with cushion or objects. The room around you has quite alot of reverb that affects your sound quality.

jasondoubleoseven
Автор

Very informative Video, Can you please create a Video with CICD implementation like trigger the webhook whenever contract gets created or updated

rahulanwekar
Автор

Very good explanation. Wish there was no background music throughout though.

PalBose
Автор

Which role we are playing here consumer or provider and what are the files to be added when we are doing contract testing

bollineniharitha
Автор

I'm really confused which environment the Provider is run in, if you're meant to run Contract tests _before_ deploying then where is the API URL pointing to? You can't point to a dev environment because that'll have the old code.

ElvenSpellmaker
Автор

can u share the code snippet in github please

pramodmallick
Автор

great video, next time sit closer the microphone.

carlconn