android - How to test my current activity after intent with Robotium -
i have tedious problem robotium. while test robotium, if gone secondactivity clicking button in firstactivity, robotium can checked secondactivity assertcurrentactivity() method.
for instance activity opened, button clicked , b activity opened , assertcurrentactivity(b) returns true.
hovewer; if applicaiton started in oncreate method in activity, b activity opened robotium can not checked assertcurrentactivity(b). says still current activity activity.
mainactivity.class
@override public void oncreate( bundle savedinstancestate ) { super.oncreate( savedinstancestate ); setcontentview( r.layout.activity_main ); selector(); sharedprefenceshelper.setapplaunched( true ); periodscount = periodlistordering.getallperiodsize(); if ( periodscount < 0 ) intentcalendaractivity(); replacenewfragment( entryfragment.newinstance( ), entrypage_fragment_tag ); }
intentcalendaractivity() method send calendaractivity.class , calendaractivity correctly opened.
my test code
public void testscenario1() { // kilidi aç solo.unlockscreen(); // db içindek tüm periodları sil. mydatabasequery.clearperioddb(); // calendaractivity için ne olur ne olmaz diye bekleme yapalım. solo.waitforactivity( "calendaractivity" ); // takvimi doğrula. solo.assertcurrentactivity( "calendaractivity not found", "calendaractivity" ); // hiç bişey yapmadan geri dön. solo.goback(); // nodatamessageactivity acitivity e gönderilmelidir. solo.waitforactivity( no_data_message_activity ); // nodatamessageactivity gittiğini doğrula solo.assertcurrentactivity( no_data_message_activity + " not found", no_data_message_activity ); // bir şey yapmadan geri dön solo.goback(); }
message come robotium
junit.framework.comparisonfailure: calendaractivity not found expected:<[calendar]activity> was:<[main]activity> @ com.robotium.solo.asserter.assertcurrentactivity(asserter.java:43) @ com.robotium.solo.solo.assertcurrentactivity(solo.java:972) @ com.bitbar.recorder.extensions.extsolo.assertcurrentactivity(extsolo.java:193) @ com.medyasef.she.nodataactivitytest.testscenario1(nodataactivitytest.java:54) @ java.lang.reflect.method.invokenative(native method) @ android.test.instrumentationtestcase.runmethod(instrumentationtestcase.java:214) @ android.test.instrumentationtestcase.runtest(instrumentationtestcase.java:199) @ android.test.activityinstrumentationtestcase2.runtest(activityinstrumentationtestcase2.java:192) @ android.test.androidtestrunner.runtest(androidtestrunner.java:190) @ android.test.androidtestrunner.runtest(androidtestrunner.java:175) @ android.test.instrumentationtestrunner.onstart(instrumentationtestrunner.java:555) @ android.app.instrumentation$instrumentationthread.run(instrumentation.java:1661)
Comments
Post a Comment