Mocking super implementation using powermock
This is a terrible idea and a dirty hack.
If it is part of your subject under test, you should never do this kind of thing, since you are testing the behavior of this whole class, not just part of it.
If you really need to do this, you can extend the class and override the processRetrievedData method so that it doesn't call super - this way you stub out that method.
source to share
While this is bad practice, sometimes you need to mock inheritance when working in an environment where there is no choice. For example, I needed to mock superclass methods in a dialog snippet in Android to isolate my unit tests. In your case, as part of your test use ...
@PrepareForTest(ChildClass.class)
public class ChildClassTest {
@Test
public void testMethod() {
PowerMockito.suppress(PowerMockito.method(SuperClass.class, "processRetrievedData"))
// Run method and test
}
}
There are other overloaded methods listed in the API in the MemberMatcher class that are useful in other cases, such as the method has parameters, there are additional inherited methods, etc. Hope it helps.
source to share