Summary
This has been more of a reflective chapter where you learned some tips to help you write better tests. Examples from earlier and later chapters were used to help reinforce the ideas and guidance. You’ll write better tests if you make sure to consider the following items:
- The tests should be easy to understand with descriptive names.
- Prefer small and focused tests instead of large tests that try to do everything.
- Make sure that tests are repeatable. If a test fails once, then it should continue to fail until the code is fixed.
- Once you test something, you don’t need to keep testing the same thing. And if you have some useful code that other tests can share, then consider putting the code in its own project with its own set of tests. Only test the code that is in your project.
- Test what should happen instead of how it should happen. In other words, focus less on the internal steps and instead verify the results you are most interested in...