I'm trying to unit test a class that references static data from another class. I cannot "not" use this static class, but obviously running multiple tests has become problematic. So my question is this. Is there a way in a junit test to reinitialize a static class? That way one test is not effected by a previous test?
So in other words some way of doing this:
Foo.setBar("Hello");
// Somehow reinitialize Foo
String bar = Foo.getBar(); // Gets default value of bar rather than "Hello"
Unfortunately, I cannot change Foo, so I'm stuck using it.
Edit It appears I made my example a bit too simple. In the real code "Bar" is set by a system property and gets set to an internal static variable. So once it starts running, I can't change it.