Spring Cloud Contract : Write Contract Test for multiple consumer with different or partially different expectations










2















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.










share|improve this question




























    2















    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.










    share|improve this question


























      2












      2








      2








      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.










      share|improve this question
















      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






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 18 '18 at 16:35







      Prabhat Ranjan

















      asked Nov 15 '18 at 17:55









      Prabhat RanjanPrabhat Ranjan

      15211




      15211






















          2 Answers
          2






          active

          oldest

          votes


















          2














          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)





          share|improve this answer























          • 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


















          2














          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.






          share|improve this answer























            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
            );



            );













            draft saved

            draft discarded


















            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









            2














            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)





            share|improve this answer























            • 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















            2














            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)





            share|improve this answer























            • 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













            2












            2








            2







            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)





            share|improve this answer













            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)






            share|improve this answer












            share|improve this answer



            share|improve this answer










            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

















            • 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













            2














            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.






            share|improve this answer



























              2














              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.






              share|improve this answer

























                2












                2








                2







                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.






                share|improve this answer













                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.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 18 '18 at 16:39









                Prabhat RanjanPrabhat Ranjan

                15211




                15211



























                    draft saved

                    draft discarded
















































                    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.




                    draft saved


                    draft discarded














                    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





















































                    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







                    Popular posts from this blog

                    Top Tejano songwriter Luis Silva dead of heart attack at 64

                    ReactJS Fetched API data displays live - need Data displayed static

                    政党