Skip to content

This repository aims to exemplify, in a simple and practical way, the execution of contract tests with Pact using different languages for each application.

License

Notifications You must be signed in to change notification settings

acmachado14/simple-pact

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Contract Testing with Pact


Description

This repository aims to exemplify, in a simple and practical way, the execution of contract tests with Pact using different languages for each application.

Flow

The flow used is as simple as possible to carry out the communication of the provider and consumer tests. It is far from ideal for use in software productions! If you want a complete flow for your application, I recommend Nirvana for contract test which makes use of CI for verification steps.

Pact Broker

The Pact Broker is responsible for the communication between the systems, ensuring the execution of the tests On both sides. Thus, the consumer sends the contract containing the information he expects to receive on a given route. and the provider downloads this contract, executes it locally, checking if the data is being sent as expected and returns test results for the Pact Broker.

Prerequisites

Run Pact Broker

docker-compose up

Consumer

O consumer it is the application that consumes the API, it is responsible for making data requests to the provider.

Prerequisites

  • Docker

Install

make build

Run terminal in docker

make run-it

Run tests

npm run test:consumer

Publish the contract

npm run pact:publish

Provider

The provider is the application that promotes the API, is responsible for sending the data requested by the consumer.

Prerequisites

  • PHP
  • composer

Up the application

php -S localhost:8000

Run tests

vendor/bin/phpunit

About

This repository aims to exemplify, in a simple and practical way, the execution of contract tests with Pact using different languages for each application.

Topics

Resources

License

Stars

Watchers

Forks