#code #implementation #software #test
idea
Contract testing validates the stability of a dependency's contract. There are two use-cases for such test:
as a client
Unit testing is easier when using test doubles, rather than actual integration tests. However, contracts might change. The contract testing is used to validate that the test-double's interface is consistent with the actual dependency contract. To be useful, the contract test must reproduce the same calls as to the test double.
as a producer
Guarantee service stability by validating that the contract offered to consumers is not changed.
links
Clean code: Contract testing allows separation of concern for testing code itself and consistency of dependencies, making the code cleaner.