-
Notifications
You must be signed in to change notification settings - Fork 238
Can't use @Mocked on Base classes anymore #236
Copy link
Copy link
Closed
Labels
Description
I encountered an issue (?) with JMockit 1.20. Until 1.19 I was able to annoted a Base class with @mocked and I could record some behaviour. Since 1.20 the behaviorz changed. The object is mocked but instead of returning the values recorded in the Expectations it provides just the default values.
public final class MockingBaseClassTest {
static class Base {
int getIntValue() { return 1; }
}
static class Bar extends Base {
int doSomething() { return 1 + getIntValue(); }
}
@Test
public void failsInJMockit120(@Mocked final Base foo) throws Exception {
new Expectations() {{
foo.getIntValue(); result = 9;
}};
// the result in 1.20
Assert.assertEquals(9, new Bar().doSomething());
// the result in 1.19
Assert.assertEquals(10, new Bar().doSomething());
}
}
Hopefully this is clear enough. Thanks in advance.
Reactions are currently unavailable