Mockito を使用して、オブジェクトのメソッドを呼び出すとスーパー実装が呼び出されるかどうかをテストできますか? これを行う方法が見つかりません。基本的に私はこのようなものが欲しい:
@RunWith(RobolectricTestRunnerWithInjection.class)
public class TestFragmentTest {
@Spy private TestFragment testFragment;
@Test
public void onConfigurationChanged_shouldNotCallSuper() {
doThrow(new RuntimeException("Should not call super!")).when(superOf(testFragment))
.onConfigurationChanged(null);
testFragment.onConfigurationChanged(null);
}
private static class TestFragment extends Fragment {
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
}
}
}
もちろんsuperOf
、Mockito にはユーティリティはありませんが、これは私が探している動作を表しています。