Expectation recorded on superclass method on subclass object is overwritten if same expectation is recorded on different subclass object.
Best shown on following unit test (testng 6.9.6, jmockit 1.19) which I would expect to pass.
Is it bug? If not, could you elaborate on why it fails?
public class SpikeTest {
public static class First extends Parent {
}
public static class Second extends Parent {
}
public static abstract class Parent {
public String getValue() {
return "parent";
}
}
@Mocked
private First first;
@Mocked
private Second second;
@Test
public void test() throws Exception {
new Expectations() {{
first.getValue();
result = "first";
second.getValue();
result = "second"; //this recording overwrites previous recording on first object
}};
assertEquals(second.getValue(), "second");
assertEquals(first.getValue(), "first"); //fails here, recorded "first" value is overwritten by "second"
}
}
Expectation recorded on superclass method on subclass object is overwritten if same expectation is recorded on different subclass object.
Best shown on following unit test (testng 6.9.6, jmockit 1.19) which I would expect to pass.
Is it bug? If not, could you elaborate on why it fails?