PowerMock does not support '@InjectMocks' annotations on superclasses of a
testclass. This feature has been improved in Mockito 1.9.0 and is particularly
useful for testing applications that make extensive use of Dependency Injection.
Here is an example that demonstrates the problem (it throws a
NullPointerException):
interface Something {
void invoke();
}
class ObjectUnderTest {
private final Something _something;
ObjectUnderTest(final Something something) {
_something = something;
}
void performOperation() {
_something.invoke();
}
}
@Ignore
public abstract class BaseTest {
@Mock
Something _something;
@InjectMocks
ObjectUnderTest _objectUnderTest;
@RunWith(PowerMockRunner.class)
public static class PerformOperationTest extends BaseTest {
@Test
public void performsTheOperation() {
_objectUnderTest.performOperation();
verify(_something).invoke();
}
}
}
Original issue reported on code.google.com by ewald.s...@gmail.com on 19 Aug 2011 at 7:38
Original issue reported on code.google.com by
ewald.s...@gmail.com
on 19 Aug 2011 at 7:38Attachments: