lundi 2 mars 2015

Android Testing with ActivityInstrumentationTestCase2

I'm using ActivityInstrumentationTestCase2 to test my activities.


When I start the test, I can see all is fine on the first activity, but when I call another activity in my test, the test of this new activity wasn't call, why ?


The new activity is showed, but nothing happens in the test.


I call my another activity like that :



ActivityMonitor receiverActivityMonitor = getInstrumentation().addMonitor(HomeActivity.class.getName(), null, false);
TouchUtils.clickView(this, layBtn);

HomeActivity receiverActivity = (HomeActivity) receiverActivityMonitor.waitForActivityWithTimeout(TIMEOUT_IN_MS);
assertNotNull("HomeEnergieActivity is null", receiverActivity);
assertEquals("Monitor for HomeActivity has not been called", 1, receiverActivityMonitor.getHits());

// Remove the ActivityMonitor
getInstrumentation().removeMonitor(receiverActivityMonitor);

Aucun commentaire:

Enregistrer un commentaire