Version of JMockit that was used:
1.49 (also in master branch at 5c6a2dfc6042ebf8d99770a7e9167bf3c26149e8)
Description of the problem or enhancement request:
Consider this test scenario
public static class BaseClass {
protected int doSomething() { return 1; }
}
public static class Subclass extends BaseClass {
@Override protected int doSomething() { return super.doSomething() + 1; }
}
public static final class FakeForSubclass extends MockUp<Subclass> {
@Mock public int doSomething(Invocation inv) { return inv.proceed(); }
}
When a test uses FakeForSubclass and creates an instance of Subclass, calling subclass.doSomething() results in a StackOverflowError.
Initially the invocation proceeds to run the code on Subclass, which calls the method on the base class that it overrides.
This call is intercepted by FakeForSubclass, which calls the code in Subclass again, resulting in a loop that ends in the StackOverflowError. The code in BaseClassshould be called instead.
I created a pull request that adds a validation for this issue on the FakedClassWithSuperClassTest: #704
Version of JMockit that was used: 1.49 (also in master branch at 5c6a2dfc6042ebf8d99770a7e9167bf3c26149e8)
Description of the problem or enhancement request:
Consider this test scenario
When a test uses
FakeForSubclass
and creates an instance ofSubclass
, callingsubclass.doSomething()
results in a StackOverflowError.Initially the invocation proceeds to run the code on
Subclass
, which calls the method on the base class that it overrides.This call is intercepted by
FakeForSubclass
, which calls the code inSubclass
again, resulting in a loop that ends in the StackOverflowError. The code inBaseClass
should be called instead.I created a pull request that adds a validation for this issue on the FakedClassWithSuperClassTest: #704