I
I
illuzor2015-12-25 14:37:22
Android
illuzor, 2015-12-25 14:37:22

android testing. How to do something before activity creation?

Greetings. I'm learning texting.
The following situation has arisen: you need to test the login screen. If the application is launched first, everything is OK, if not, the settings are saved and login occurs automatically after the application is launched. Because of this, the tests do not have time to pass, as another activity opens.
I would like to reset the settings before launching the activity. But here is the problem, in the test class, the activity is launched immediately in the constructor, and the constructor is strictly required. Is there a way out of this situation?

public class StartActivityTest extends ActivityInstrumentationTestCase2<StartActivity>{

    StartActivity activity;

    public StartActivityTest() {
        super(StartActivity.class);  // тут происходит запуск. Хотелось бы сбросить настройки до этого запуска.
    }

    @Override
    protected void setUp() throws Exception {
        super.setUp();
        activity = getActivity();
    }

    @SmallTest
    public void testTest(){
        assertEquals("4", "5");
    }
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question