Giter Club home page Giter Club logo

thoughtworks-vodqa-contract-testing's Introduction

thoughtworks-vodqa-contract-testing

This reposiroty consists of code used for demo in talk give at "Thoughtworks vodqa, Pune" for contract testing on 01-Aug-2020

Setup instructions:

1. Setting up pack broker:

  1. Clone this repository.

  2. Start docker in the machine. Install docker in your machine from here if you dont have it.

  3. Navigate to the root folder level of the cloned repository and bring up the pact broker in docker using below command.

    docker-compose up

    The docker compose file pulls the pact-broker image and also spawns up the prostgres DB which is used by pact-broker to store data. Dive into the compose file for more understanding.

  4. If every thing goes well, you should be able to access the pact broker UI at http://localhost:9292


2. Setting up the consumers and provider in IDE:

  1. We have two consumers and one provider for the setup. (There are actually three different projects. I have pushed then into a single repo for ease of cloning.)
  2. Import the consumer_one, consumer_two and provider_one into three different instances of your IDE respectively.

3. Running the contract tests:

3.1 consumer_one:

  1. Open consumer_one in IDE.

  2. Execute the gradle task to run the contract tests of consumer_one with below command.

    ./gradlew contractTest

     If everything goes well, the test runs successfully and you should be able to see
     a pact json file in 'build>pacts>consumer_two-provider_one.json'
    
  3. Execute the gradle task to publish this pact to the pact-broker running in docker with below command.

    ./gradlew pactPublish

  4. Go to the pact-broker UI (link in the Setting up pack broker above) and you should be able to see the pact of consumer_one in this UI

3.2 consumer_two:

  1. Repeat the same process as mentioned for consumer_one.

3.3 provider_one:

  1. Open provider_one in IDE.

  2. Execute the gradle task to verify the contracts from the pact-broker with below command.

    ./gradlew contractTest

     This task will verify the pacts of both the consumers published in pact-broker.
    
  3. For the current setup, all the tests should come out green.


Experiment with the setup changing the pacts, repeat the process and run the contract tests, they should fail. The best way to learn is to do !

GOD SPEED !!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.