Handling errors in setup and teardown
Bugs can be found anywhere in code, and that includes inside the setup and teardown code. So, how should these bugs be handled? In this section, you’ll see that there is no single way to deal with bugs in setup and teardown. It’s more important that you be aware of the consequences so that you can write better tests.
Let’s start at the beginning. We’ve already sidestepped a whole class of problems related to multiple setup and teardown declarations. We decided that these would simply be allowed instead of trying to prevent them. So, a test can have as many setup and teardown declarations as it wants. Additionally, a test suite can declare as many instances of setup and teardown as needed.
However, just because multiple instances are allowed doesn’t mean that there won’t be any problems. The code that creates the test data entries is a good example. I thought about fixing the problem in the code but...