“As a team, we commit to test-first development, preferring unit tests over integration tests, and reluctantly accepting integration tests over no tests at all. As such, we write just enough integration tests to provide end to end smoke testing and no more.”
In distinguishing between unit tests and integration tests, we honor the following foundational practices to which we largely credit Kent Beck, Michael Feathers, and Bob Martin.
- You are not allowed to write any production code unless it is to make a failing unit test pass.
- You are not allowed to write any more of a unit test than is sufficient to fail; and compilation failures are failures.
- You are not allowed to write any more production code than is sufficient to pass the one failing unit test.
- A test is not a unit test (but is instead an integration test) if:
- it talks to the database
- it communicates across the network
- it touches the file system
- it can’t run at the same time as any of your other unit tests
- you have to do special things to your environment (such as editing config files) to run it.
5. Above all else, be pragmatic and use your judgment.