-
Notifications
You must be signed in to change notification settings - Fork 238
Super Constructor Gets Called Wrongly #492
Copy link
Copy link
Closed
Labels
Description
Please provide the following information:
-
Version of JMockit that was used: 1.36.3
-
Description of the problem: Super constructor always gets called when trying to use mocking API to override constructor
Example test:
import mockit.Expectations;
import org.junit.Test;
public class FailedTest {
@Test
public void foo() {
new Expectations(B.class) {{
new B(anyString);
times = 1;
}};
new B(""); // Always throws a null pointer exception due to `System.out.println(x.length());` below
}
class A {
A(String x) {
System.out.println(x.length());
}
}
class B extends A {
B(String x) {
super(x);
}
}
}Reactions are currently unavailable