Spring Cloud Contract : Write Contract Test for multiple consumer with different or partially different expectations
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.
java spring spring-boot spring-cloud spring-cloud-contract
add a comment |
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.
java spring spring-boot spring-cloud spring-cloud-contract
add a comment |
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.
java spring spring-boot spring-cloud spring-cloud-contract
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.
java spring spring-boot spring-cloud spring-cloud-contract
java spring spring-boot spring-cloud spring-cloud-contract
edited Nov 18 '18 at 16:35
Prabhat Ranjan
asked Nov 15 '18 at 17:55
Prabhat RanjanPrabhat Ranjan
15211
15211
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
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)
Well this was not really my question. But I would still mark it accepted because I could not even find this in my first attempt. I had read through a lot of git hub issues to come to the point of your answer. I will also change my question a little.
– Prabhat Ranjan
Nov 18 '18 at 16:34
I assumed that was causing the problem. Do you still have this issue after applying that change?
– OlgaMaciaszek
Nov 18 '18 at 16:39
1
No I was able to figure it out. But thanks for the response.
– Prabhat Ranjan
Nov 18 '18 at 16:40
add a comment |
Adding more to @OlgaMaciaszek,
There is possiblity of specifying consumerName
which must be the same as the sub-folder name in producers /contract
folder.
One may choose to skip providing the consumerName
by using application name specified in application.yaml. But this also means that the subfolder in producer's contract folder must be same as the application name of consumer.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53325332%2fspring-cloud-contract-write-contract-test-for-multiple-consumer-with-different%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
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)
Well this was not really my question. But I would still mark it accepted because I could not even find this in my first attempt. I had read through a lot of git hub issues to come to the point of your answer. I will also change my question a little.
– Prabhat Ranjan
Nov 18 '18 at 16:34
I assumed that was causing the problem. Do you still have this issue after applying that change?
– OlgaMaciaszek
Nov 18 '18 at 16:39
1
No I was able to figure it out. But thanks for the response.
– Prabhat Ranjan
Nov 18 '18 at 16:40
add a comment |
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)
Well this was not really my question. But I would still mark it accepted because I could not even find this in my first attempt. I had read through a lot of git hub issues to come to the point of your answer. I will also change my question a little.
– Prabhat Ranjan
Nov 18 '18 at 16:34
I assumed that was causing the problem. Do you still have this issue after applying that change?
– OlgaMaciaszek
Nov 18 '18 at 16:39
1
No I was able to figure it out. But thanks for the response.
– Prabhat Ranjan
Nov 18 '18 at 16:40
add a comment |
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)
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)
answered Nov 16 '18 at 14:42
OlgaMaciaszekOlgaMaciaszek
1,4801520
1,4801520
Well this was not really my question. But I would still mark it accepted because I could not even find this in my first attempt. I had read through a lot of git hub issues to come to the point of your answer. I will also change my question a little.
– Prabhat Ranjan
Nov 18 '18 at 16:34
I assumed that was causing the problem. Do you still have this issue after applying that change?
– OlgaMaciaszek
Nov 18 '18 at 16:39
1
No I was able to figure it out. But thanks for the response.
– Prabhat Ranjan
Nov 18 '18 at 16:40
add a comment |
Well this was not really my question. But I would still mark it accepted because I could not even find this in my first attempt. I had read through a lot of git hub issues to come to the point of your answer. I will also change my question a little.
– Prabhat Ranjan
Nov 18 '18 at 16:34
I assumed that was causing the problem. Do you still have this issue after applying that change?
– OlgaMaciaszek
Nov 18 '18 at 16:39
1
No I was able to figure it out. But thanks for the response.
– Prabhat Ranjan
Nov 18 '18 at 16:40
Well this was not really my question. But I would still mark it accepted because I could not even find this in my first attempt. I had read through a lot of git hub issues to come to the point of your answer. I will also change my question a little.
– Prabhat Ranjan
Nov 18 '18 at 16:34
Well this was not really my question. But I would still mark it accepted because I could not even find this in my first attempt. I had read through a lot of git hub issues to come to the point of your answer. I will also change my question a little.
– Prabhat Ranjan
Nov 18 '18 at 16:34
I assumed that was causing the problem. Do you still have this issue after applying that change?
– OlgaMaciaszek
Nov 18 '18 at 16:39
I assumed that was causing the problem. Do you still have this issue after applying that change?
– OlgaMaciaszek
Nov 18 '18 at 16:39
1
1
No I was able to figure it out. But thanks for the response.
– Prabhat Ranjan
Nov 18 '18 at 16:40
No I was able to figure it out. But thanks for the response.
– Prabhat Ranjan
Nov 18 '18 at 16:40
add a comment |
Adding more to @OlgaMaciaszek,
There is possiblity of specifying consumerName
which must be the same as the sub-folder name in producers /contract
folder.
One may choose to skip providing the consumerName
by using application name specified in application.yaml. But this also means that the subfolder in producer's contract folder must be same as the application name of consumer.
add a comment |
Adding more to @OlgaMaciaszek,
There is possiblity of specifying consumerName
which must be the same as the sub-folder name in producers /contract
folder.
One may choose to skip providing the consumerName
by using application name specified in application.yaml. But this also means that the subfolder in producer's contract folder must be same as the application name of consumer.
add a comment |
Adding more to @OlgaMaciaszek,
There is possiblity of specifying consumerName
which must be the same as the sub-folder name in producers /contract
folder.
One may choose to skip providing the consumerName
by using application name specified in application.yaml. But this also means that the subfolder in producer's contract folder must be same as the application name of consumer.
Adding more to @OlgaMaciaszek,
There is possiblity of specifying consumerName
which must be the same as the sub-folder name in producers /contract
folder.
One may choose to skip providing the consumerName
by using application name specified in application.yaml. But this also means that the subfolder in producer's contract folder must be same as the application name of consumer.
answered Nov 18 '18 at 16:39
Prabhat RanjanPrabhat Ranjan
15211
15211
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53325332%2fspring-cloud-contract-write-contract-test-for-multiple-consumer-with-different%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown