I have 2 integration tests implemented with JUnit. Both of the tests perform calls to the remote server and the server target is configured by environment variable:
System.setProperty("property", "value1");
The tricky thing is that those properties must be different for 2 tests. If I set the environment variable for each unit test it does not work, because the middleware that we are using caches the property value on first call and does not evaluate it anymore (for the second test).
I believe the solution could be to run those unit tests in separate processes. I saw similar discussion here, but maybe there is more elegant way fo doing this with JUnit4? This problem looks pretty common. Or maybe there are another ways to run unit tests with different configuration?
Thanks in advance for any advices.