Hi everyone, I wondering how to go about writing a...
# general
a
Hi everyone, I wondering how to go about writing a contract test for a monolith application (written in PHP). I'm new to pact and as I understand it, an advantage of contract testing is that you don't need to stand up all services like in a managed environment. In the case of this monolith app, there are quite a few dependencies e.g. redis, MYSQL, nginx. I understand that when writing the consumer test, pact provides a mock provider which tests the pact in that case. When verifying the pact against the provider (monolith in this case), do I need to stand up the monolith app as well as the dependencies I mentioned in order to verify the pact?
m
You need to stand up as much of your monolith as needed to verify the contract. If you can avoid standing up redis, MySQL etc. and instead replace them with in-memory stubs that is entirely up to you. Just be careful that whatever you mock, you may need a separate test for the mocked behaviour to ensure it continues to work as expected
m
As I understood contract testing the intention is to only test the interface between the consumer and provider. Involving any dependencies sounds like a bad idea to me since then you would end up with a function test. For my contract tests, I involve only the client code of the consumer and the controller code of the provider.
m
That's true, but if there is no harm in also testing the function and/or if it is convenient to do so that's a good starting point for many
a
Thanks all for the suggestions
👍 1