I have this setup:
@Tested
private ClassUnderTest classUnderTest;
@Mocked
private MockedType1 mockedType1;
@Mocked
private MockedType2 mockedType2;
public class CustomExpectations extends Expectations {
public CustomExpectations() {
mockedType1.function1();
result = result1;
result1.function2();
result = mockedType2;
mockedType2.functionMockedType2();
result = result2;
}
}
Then, I have some tests that use this CustomExpectations class to do some setup, and then a more generic inline expectation with the rest of the code covered. The issue I'm finding is that, when the expectation
mockedType2.functionMockedType2();
result = result2;
is on the CustomExpectations class, the function call always returns null. If I move that expectation to the inline expectation, it works fine.
It is possible to do what I'm trying to do? I've tried to pass mockedType2 as a parameters to the CustomExpectations, but it still returns null.