A photo of Geoffrey Hayward

JUnit Testing

Illustration of Java code resetting a singleton in a JUnit.

Java JUnit: Reset a singleton

February 28, 2018

Java singleton’s are hard to unit test because the state of the singleton is altered as each test runs. But for testing sake you can reset the singleton’s state use reflection. Here is an example that worked for me.

Continue reading