authorjapps / zerocode

A community-developed, free, opensource, automated testing framework for microservices APIs, Kafka(Data Streams) and Load testing. Zerocode Open Source enables you to create, change and maintain your automated test scenarios via simple JSON or YAML files. Visit documentation below:
https://zerocode-tdd.tddfy.com
Apache License 2.0
887 stars 389 forks source link

Mocking - Integrate WireMock for downstream REST api dependencies #47

Closed authorjapps closed 6 years ago

authorjapps commented 6 years ago

e.g. You are developing a REST api GET:/api/v1/persons/p001

Many times while designing an integration test we need to mock GET:/api/v1/addresses/pid/p001 to provide response as e.g.

GET:/api/v1/addresses/pid/p001
Response:
{
   "personId": "p001",
   "address": { 
          "line1" : "10 Downing Street"
    }
}

Then the GET person will respond with:

GET:/api/v1/persons/p001
Response:
{
   "personId": "p001",
   "name": "Peter",
   "age": 33,
   "address": { 
          "line1" : "10 Downing Street"
    }
}
authorjapps commented 6 years ago

Implemented. Release version 1.1.31

See working examples here: https://github.com/authorjapps/zerocode-hello-world/blob/master/src/test/resources/wiremock_tests/mock_via_wiremock_then_test_the_end_point.json