如何通过AndroidJUnit4快速启动一个activity,并且不自动退出

@RunWith(AndroidJUnit4.class)
public class VanillaActivityTest {

@Rule
public final ActivityTestRule activityTestRule =
new ActivityTestRule<>(VanillaActivity.class, false, false);

@Test
public void blockingTest() throws Exception {
Intent intent = new Intent();
// Add your own intent extras here if applicable.
activityTestRule.launchActivity(intent);
CountDownLatch countdown = new CountDownLatch(1);
countdown.await();
}

}

原文:http://stackoverflow.com/questions/42299276/android-directly-launch-the-activity-fragment-that-is-under-development

你可能感兴趣的:(技术讨论)