contract-testing-demo

pact and java contract testing with micro-commits

git clone https://9o.is/git/contract-testing-demo.git

commit dffe062ce81d04dcdd88a764202f68ad08c63845
parent 71d87a9a485c7aef87587d3edf6ef49f9dd60e84
Author: Jul <jul@9o.is>
Date:   Wed, 26 Jun 2019 16:10:16 -0400

Write failing provider test

Test:
Given the service is unavailable, upon receiving a request for Mary the
alligator, a 500 is returned.

Diffstat:
Mconsumer-driven/animal-service/src/test/java/app/ZooServicePactTest.java | 14+++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/consumer-driven/animal-service/src/test/java/app/ZooServicePactTest.java b/consumer-driven/animal-service/src/test/java/app/ZooServicePactTest.java @@ -61,7 +61,19 @@ public class ZooServicePactTest { verify(alligatorRepository).getByName("Mary"); } - public void animalServiceIsUnavailable() {} + @State("the service is unavailable") + public void animalServiceIsUnavailable() { + when(alligatorRepository.getByName("Mary")) + .thenThrow(RuntimeException.class); + } + + @State( + value = "the service is unavailable", + action = StateChangeAction.TEARDOWN + ) + public void animalServiceIsUnavailableVerification() { + verify(alligatorRepository).getByName("Mary"); + } @Before public void before() {