Differences between unit tests and other tests
Which of these practices are recommended for:
- only unit tests
- all kinds of automated tests (unit, system, component)
- tests that aren’t unit tests (system, component)
- never
Practices:
- Only one assertion in each test case
- An expert should check the test result is correct every time you execute it
- You should have 100% line coverage when you run the tests
- Test against a public api not a private api
- Avoid overspecifying. Check only certain properties and details, not the whole output.
- Write the tests only after the code to be tested is implemented and design is stable.
- Use a white-box testing approach, you will find more bugs.
- Use a black-box testing approach, your test will be less fragile.
- Use Exploratory testing.
- Use Capture-replay testing.
- Use Pairwise (all-pairs) testing.
- Use Data-driven testing.