pact-foundation / pact-mock_service

Provides a mock service for use with Pact
https://pact.io
MIT License
73 stars 69 forks source link

Count the number requests matching an interactions #105

Closed AMCR closed 5 years ago

AMCR commented 5 years ago

On this PR we coded an additional feature for pact-mock-service that allow the users to know how many times an interaction matched. This can be useful in scenarios where we need to call the same interaction multiple times and we need to validate the number of calls (Issue #107).

The output looks like:

[
  { 
    "description": "InteractionDescription1",
    "request": {
       "path": "/test",
       "method":"GET"
    },
    "number_matches": 3,
  },
  ....
]
bethesque commented 5 years ago

Hi @AMCR. Thank you for you work on this PR. I appreciate the quality of your code and your excellent test coverage, and documentation updates!

Unfortunately, I won't be merging it however. Pact is a contract testing framework, not a generalized mocking framework. Pact needs to do what it does best, without attempting to support features that already far better supported in other frameworks that are designed to provide fully featured mocks.

If you care how many times a request is made, then I suggest that you use a separate test for that, with a mocking framework that supports your assertions.

I hope this makes sense, and I thank you again for the time you spent making this a quality PR.