Supporting test setup and teardown
In order to support test setup and teardown, we only need to arrange for some code to run before a test begins and for some code to run after a test finishes. For the setup, we might be able to simply call a function near the beginning of the test. The setup doesn’t actually have to run before the test, as long as it runs before the test needs the setup results. What I mean is that the unit test library doesn’t really need to run the setup before a test begins. As long as the test itself runs the setup at the very beginning of the test, then we get the same overall result. This would be the simplest solution. It’s not really a new solution at all, though. A test can already call other functions.
The biggest problem I see with simply declaring a standalone function and calling it at the start of a test is that the intent can get lost. What I mean is that it’s up to the test author to make sure that a function called within...