4 ms·
No, Settings/Configuration is a classic example of where using a Singleton horribly breaks testability, because you can't run multiple "application runs" in the
by misterbee 15y ago
No, Settings/Configuration is a classic example of where using a Singleton horribly breaks testability, because you can't run multiple "application runs" in the same "test run" without completely exiting and rebuilding the app runtime environment.
- Confusion 15y agoTesting frameworks exit and rebuild the app runtime environment all the time, to isolate the effects of one test case from the next. When your singleton instantiation is paramatrized, for instance with a configuration file, than there is no testability problem whatsoever. I would go as far as to say that if you have to do multiple "application runs" in the same "test run", where these "application runs" require different configurations to have the test cover some specific scenario, then your code has larger problems than having the configuration in a singleton.