Contract tests
"Integration Tests are a Scam" Joe Rainsberger
Topalov Alex @sharkzp
Problem:
- The larger application the larger amount of time you need to test it.
-
The more integration(end-to-end) test you wrote the more duplication you involve.
-
When integration test fails who knows what part of code is broken.
Object under test
Object under test diagram, by Sandi Metz
What does it mean?
Goals of unit tests
-
Thorough: must prove completely that the single object under test is behaving correctly
-
Stable: must not break with an implementation detail change
-
Fast: minimize development feedback loop
-
Few: Each test should prove one unitary behaviour of public interface
If Unit test intend to test only one object, and integration tests does not provide great feedback what we should do?
Testing Pyramid
Solution: Contact test
Goal of contract test:
1. Thorough: you must prove that contract between two objects behaving correctly
2. Stable: should not say how objects should behave, should expect correct answer instead.
3. Fast: minimize development feedback loop
4. Few: Each test should prove one unitary behaviour of public interface
Example
Credits:
- J. B. (Joe) Rainsberger - Integration Tests Are a Scam
- Ruby Conf 12 - Boundaries by Gary Bernhardt
-
destroyallsoftware.com
- Clean code - Robert C. Martin
- Bogus
Contract tests
By Alex Topalov
Contract tests
- 2,720