The test that fails only after another test
transcript
Test 2 passes when you run it alone. Run the whole suite, and it fails. You didn't change a thing. So what did?
Test 1 sets the tax rate to 12 percent. Total: 560. Fine. Test 2 never touches the rate. It expects the default. 590. It gets 560. Test 1's change is still there.
The config is one object. It lives as long as the program. So it outlives test 1. Test 2 sees what test 1 left behind.
Here's the catch. The checkout never mentions a config. It reaches for a global. A hidden dependency. A silent leak.
Give the checkout its config in the constructor. Each test builds its own. 12 percent in one, the default in another. Now the order doesn't matter. Nothing leaks. Run them in any order, or all at once.
A Singleton is a global with a nicer name. Be handed your dependencies. Don't reach for them.
Full breakdown in the lecture.