在我的单元测试(扩展ActivityInstrumentationTestCase2<>
)中,我需要断言新活动已经开始。我这样做,但在最后一行执行只是挂起。
public void testNewActivityLaunched() throws Throwable {
TouchUtils.clickView(this, mButton); // starting new activity here
String actualActivityName = getActivity().getClass().getName().toString();
String expectedActiviyName = "my.package.com";
assertEquals(actualActivityName, expectedActiviyName);
}
答案 0 :(得分:0)
您需要创建ActivityMonitors并将其添加到instrumentation.Check http://developer.android.com/reference/android/app/Instrumentation.ActivityMonitor.html。