Keeping tests focused on specific scenarios
The previous section explained that one of the benefits of descriptive names is that they help keep your tests focused. We’re going to explore in this section various scenarios that will give you ideas for what to focus on.
Saying that a test should be focused is great. But if you don’t know how to figure out what to focus on, then it won’t help you. The advice becomes empty and frustrating.
These five cases will make the advice more meaningful. Not all of them may apply to all situations. But having these will help you, sort of like a checklist. All you need to do is think about each one and write specific tests that cover the case. The cases are as follows:
- Happy or normal: This is a common use case.
- Edge: This is a case near the transition between normal and error cases.
- Error: This is a common problem that needs to be handled.
- Not normal: This is a valid but uncommon use case.
- Deliberate...