Hello, I’ve recently joined a new project and curr...
# general
z
Hello, I’ve recently joined a new project and currently we don’t have anything to test the integration between two services. We are planning to introduce the contract testing, however, I’m curious to know if we add contract tests, do we still need to create another layer in the test pyramid to carry out the functional integration testing? Or is it possible to tweak our contract tests in such a way that just one layer of contract tests can help with functional testing as well? (I understand that it will make the tests unnecessary complicated, but just checking about the feasibility of covering functional testing as part of pact testing layer). I would like to know your opinion on this 🙂
👋 1
👍 1
m
Best to keep the functional tests separate. You get a lot of functional test for free as part of pact testing, but you won’t be able to easily test side effects and that will be hard to do with Pact in a way that’s not brittle
💯 2
👍 1
t
I agree with Matt. The way most people write contract tests, there will naturally be some functional coverage, but it is incidental / a consequence of the contract test- because some of the functional code happens to be exercised during the test. The primary reason that we don’t recommend functional testing with contract tests is that (especially in consumer driven contract testing) the consumer doesn’t know or define all the provider’s behaviour. Consider username validation- there might be many rules, but the consumer doesn’t necessarily know them.
👌 1
👍 1
In that example, the contract test can say “here is how I expect you to tell me that the username is not valid”, rather than “here are all the scenarios that the username will not be valid”
👍 1