We are doing consumer driven testing using spring-cloud-contract. I have two consumers (services) and one producer service. All of them are in different repositories. The producer has an api e.g. - /get/product/123. Each consumer has different requirements. So, I created two folders and put a getProduct.groovy file in each folder. It looks something like below:
contracts
│ ├── consumerA
│ │ ├── GetProduct.groovy
│ ├── consumerB
│ │ ├── GetProduct.groovy
Both groovy files contain different body and generate stubs in the respective folders.
In order for the stubsPerConsumer
feature to work, you need to make sure you set its flag to true in the StubRunner
setup in your consumer integration tests, like so:
@AutoConfigureStubRunner(ids = "yourids", repositoryRoot = "yourrepository",
stubsMode = StubRunnerProperties.StubsMode.REMOTE,stubsPerConsumer = true)