I have a test case that uses Instrumentation.ActivityMonitor to check if an intent has been sent. This works great when the test succeeds. If the statement fails, the following test case hangs on a call to getActivity () in setUp ().
Should I call someone to clean?
It seems to revolve around the launch of the Activity, but the ActivityMonitor will not catch it. That is, IntentFilter did not start. The test failed, but the new activity never rejects and seems to interfere with the next getActivity () call.
This problem is similar to another question , but this solution there (calling super.tearDown ()) did not fix my problem.
public class SimpleActivityTest extends ActivityInstrumentationTestCase2<SimpleActivity> { private SimpleActivity activity; @Override protected void setUp() throws Exception { super.setUp(); this.getInstrumentation().setInTouchMode(false); Intent intent = new Intent(); intent.putExtra("DATA_ITEM_1", 1); intent.putExtra("DATA_ITEM_2", 2); this.setActivityIntent(intent); this.activity = getActivity();
source share