0

I read couple articles about Consumer Contract Testing, but I cannot find answer to one question.

Let's say I have 3 microservices: A, B, C. The communication looks like that:

A -> B -> C

Now I want to test contract between A and B. Should I start services B and C or only B in mocked/stubbed mode?

tomekK
  • 101
  • 1
    Depends on what you want to do. If you want to test only the interaction between classes A and B, ignoring everything else in the application, then the C component of B should be mocked. If you want to test the interaction between the classes A and B with respect to the class C, the class C service should be part of the process as well. However, most integration tests are written to make sure all your wiring works. If you wanna run integration tests, you should not be mocking any dependencies. – Andy Apr 08 '16 at 11:28

1 Answers1

1

In the above scenario, if you're testing communication between A and B, you don't want to mock B (since you're testing it, or at least the A-facing part of B). Mocking C would be appropriate here.

Brian Agnew
  • 4,676