In my unit test (which extends ActivityInstrumentationTestCase2<>) I need to assert the new activity has been started. I do it like this but on the last line execution just hangs.
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);
}
You need to create ActivityMonitors and add them to the instrumentation.Check http://developer.android.com/reference/android/app/Instrumentation.ActivityMonitor.html.