Search in sources :

Example 1 with EvoSuiteMock

use of org.evosuite.runtime.mock.EvoSuiteMock in project evosuite by EvoSuite.

the class InstrumentingAgent_exceptionsIntTest method testExceptions.

@Test
public void testExceptions() {
    Object obj = null;
    try {
        InstrumentingAgent.activate();
        obj = new ExceptionHolder();
    } finally {
        InstrumentingAgent.deactivate();
    }
    try {
        MockFramework.enable();
        ExceptionHolder eh = (ExceptionHolder) obj;
        Assert.assertFalse(eh.getNonMockedNPE() instanceof EvoSuiteMock);
        Assert.assertTrue(eh.getMockedThrowable() instanceof EvoSuiteMock);
        StackTraceElement[] traces = new MockThrowable().getStackTrace();
        StackTraceElement[] a = eh.getTracesWhenCast();
        Assert.assertEquals(traces[1], a[1]);
    } finally {
        MockFramework.disable();
    }
}
Also used : ExceptionHolder(com.examples.with.different.packagename.agent.ExceptionHolder) EvoSuiteMock(org.evosuite.runtime.mock.EvoSuiteMock) MockThrowable(org.evosuite.runtime.mock.java.lang.MockThrowable) Test(org.junit.Test)

Aggregations

ExceptionHolder (com.examples.with.different.packagename.agent.ExceptionHolder)1 EvoSuiteMock (org.evosuite.runtime.mock.EvoSuiteMock)1 MockThrowable (org.evosuite.runtime.mock.java.lang.MockThrowable)1 Test (org.junit.Test)1