How can I test fragments with Robolectric?
Edit #4 & #5: In Robolectric 3.*, they split up the fragment starting functions. For support fragments, you will need to add a dependency to your build.gradle: testCompile “org.robolectric:shadows-supportv4:3.8” Import: org.robolectric.shadows.support.v4.SupportFragmentTestUtil.startFragment; For platform fragments, you don’t need this dependency. Import: import static org.robolectric.util.FragmentTestUtil.startFragment; They both use the same name of startFragment(). import static org.robolectric.shadows.support.v4.SupportFragmentTestUtil.startFragment; @RunWith(RobolectricTestRunner.class) … Read more