In integration testing if a test is executed on the one thread but System.exit(...) is called on another ExpectedSystemExit work unstable. If the test is finished faster then another thread calls System.exit(...) then current ExpectedSystemExit implementation fails the test.
The solution is to delay the test thread till System.exit(...) is called or time out time is finished. It's possible to use java.util.concurrent.CountDownLatch for this but I couldn't find ability to do the latch count down somewhere in NoExitSecurityManager.
P.S. if ExpectedSystemExit work as a Rule in multi-threading environment isn't break any JUnit conventions I can prepare pull request for the fix.
In integration testing if a test is executed on the one thread but
System.exit(...)is called on anotherExpectedSystemExitwork unstable. If the test is finished faster then another thread callsSystem.exit(...)then currentExpectedSystemExitimplementation fails the test.The solution is to delay the test thread till
System.exit(...)is called or time out time is finished. It's possible to usejava.util.concurrent.CountDownLatchfor this but I couldn't find ability to do the latch count down somewhere inNoExitSecurityManager.P.S. if
ExpectedSystemExitwork as aRulein multi-threading environment isn't break any JUnit conventions I can prepare pull request for the fix.