We have separated the testing of the singleton nature from the testing of the class’s functional purpose and addressed how to test the singleton nature. Testing the functional purpose is easy, right? It would be, except for one thing: we cannot construct an instance except through the singleton mechanism. The difficulty in testing the singleton’s purpose is that we have no way to test it with a Fresh Fixture. The more tests we write, the higher the chances we will create Erratic Tests. So what are our options?
Briefly, our choices are to
• Remove the singleton nature
• Make no changes and live with testing a shared fixture
• Relax the constraints on
• Or relax the constraints on construction
Let’s take a look ...