What is the difference between ActivityTestRule and IntentTestRule

while researching Testing I came across ActivityTestRule and IntentTestRule, as I understood this IntentTestRule is an extension of ActivityTestRule and is used in Espresso Intents.

But at the core is the real purpose of using these test rules.

+3


source to share


1 answer


Purpose :

to initialize Espresso-Intents before each test, annotated with @Test and issues Espresso-Intents after each test run.

@Override
protected void afterActivityLaunched() {
    Intents.init();
    super.afterActivityLaunched();
}

@Override
protected void afterActivityFinished() {
    super.afterActivityFinished();
    Intents.release();
}

      

Alternatively ,



you can use ActivityTestRule

instead of IntentsTestRule

, then in yours @Before

and @After

call manually Intents.init()

and Intents.release()

accordingly.

And the purpose of espresso intentions is

to enable validation and completion of intents sent to the application under test. This is similar to Mockito, but for Android Intents.

+3


source







All Articles