TestGenerationContext.getInstance().goingToExecuteSUTCode(); Thread.currentThread().setContextClassLoader(testClasses[0].getClassLoader()); JDKClassResetter.reset(); //be sure we reset it here, otherwise "init" in the test case would take current changed state result = runner.run(testClasses); } finally {
@After public void doneWithTestCase(){ threadStopper.killAndJoinClientThreads(); org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); org.evosuite.runtime.classhandling.JDKClassResetter.reset(); org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); }
@Test public void testReset() throws Exception { JDKClassResetter.init(); int keyValue = 1234567; //this should be fine FooKey first = new FooKey(keyValue); try{ FooKey copy = new FooKey(keyValue); fail(); } catch(Exception e){ //expected, as cannot make a copy } JDKClassResetter.reset(); //after reset, copy should be fine FooKey copy = new FooKey(keyValue); } }