@Test public void shouldUseFragmentTransactionToAddFragmentToDummyActivityIfSubjectIsAnFragment() { when(testCase.getTestSubjectClassType()).thenReturn(RoboFragment.class); when(reflectionUtils.classIsOfAssignableForm(RoboFragment.class, RoboFragment.class)) .thenReturn(true); when(reflectionUtils.createObjectProxy(RoboFragment.class, testFieldInjector)) .thenReturn(fragment); when(reflectionUtils.objectIsOfAnyType(fragment, RoboFragment.class)).thenReturn(true); testFieldInjector.setupTestCase(); TestFragmentManager fragmentManager = (TestFragmentManager) shadowOf((FragmentActivity) testFieldInjector.getCurrentContextForTest()) .getSupportFragmentManager(); assertThat(fragmentManager.getCommittedTransactions().size(), is(1)); assertThat( (RoboFragment) fragmentManager.getCommittedTransactions().get(0).getFragment(), is(fragment)); }