EasyMock Class Extension 2.3 and 2.4
When using EasyMock ClassExtension to create a stub version of an exception type that is thrown during a test by a mock collaborator of the class under test, EasyMock itself generates a NPE, instead of throwing the stub exception from the mock collaborator.
See attached. Can be run as a TestNG or JUnit test case.
When setting up the stub exception, include the following behavior:
EasyMock.expect( exception.fillInStackTrace() ).andReturn( exception );
Check whether the Throwable returned by t.getThrowable() is itself a mock object. If so, skip the fillInStackTrace() call before rethrowing it.