I'm running into a problem with some testing some classes that use the java Preferences API. The Preferences API is configured using a System property and is initialized once on first use. Thereafter, each call to get the Preferences object will return the same implementation. Some of my unit tests use one implementation, and some use another implementation, and when I run them all together in IntelliJ (or any other IDE), the later tests fail because they get a Preferences object that they did not expect. Now this is just an example, but there are tons of cases where you want the test environment to be as pristine as possible, and some singleton somewhere screws something up.
I can test in ant because its junit task allows you to fork for each test (as well as some other fork options). Is there any way to do this using intellij's junit plugin (or any other plugin)? Any other workarounds that people have found for this problem?