lundi 8 août 2016

Unit Test onSaveInstanceState with ActivityRules

I'm trying to figure out how to test onSavedInstance using the newer AndroidJunit4 and Activity Rules.

@RunWith(AndroidJUnit4.class)
public class MyViewActivityTest{

    @Rule
    public ActivityTestRule<MyViewActivity> mActivityRule = new ActivityTestRule<>(MyViewActivity.class);

    @Test
    public void testOnSavedIntanceState() {
        Intent in = new Intent();
        mActivityRule.launchActivity(in);
        MyViewActivity activity = mActivityRule.getActivity();
        activity.finish();
        activity.recreate();
    }

I get an error not sure if I am barking up the right tree.

java.lang.IllegalStateException: Must be called from main thread at android.app.Activity.recreate(Activity.java:4620)

Aucun commentaire:

Enregistrer un commentaire