当前位置: 首页 > 工具软件 > AndroidJUnit4 > 使用案例 >

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

金伟
2023-12-01

@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

 类似资料: