I have a JUnit (4) test class that uses Static variables and mocking. The static variables are being set prior to running. (Please see below as to why) However, when I run the test case, the variable are being reset to NULL. Does anyone have an explanation for this? This appears to happen after powermock has been instantiated.
My Theory
My theory is that the PowerMock creates a new Java environment inside the new Java environment so that it can isolate the mocked class redirection. I believe that this behavior started in the recent change to adding PowerMock to my application. However, I'm not sure if there is an alternative to using Static variables to accomplish the goal of the class. (Other than a dynamic class creation, which would be a little unmaintainable).
Why am I setting static variables in the test case?
I'm doing this as that this is the best that I know to set a particular setting into the test at runtime, without resorting to files. JUnitCore::run takes in the class object, but it cannot take in an initialized version of the class.