Skip navigation.

Singleton Unit Testing...

Singleton Unit Testing...

Jonathan de Halleux writes: "At first sight it may seem that Singleton and Unit Testing are not compatible since you cannot ensure the separation between the tests. We could solve the problem by instanciating a new 'Singleton' instance for each test and apply test on this 'local' instance. The problem is that a well implemented Singleton is sealed and it's constructor are private and thus you cannot create this instance."