while exploring Testing I came across ActivityTestRule and IntentTestRule as far as i have understood is this that IntentTestRule are an extension of ActivityTestRule and are used in Espresso Intents.
But at the core what is the real purpose of using these testing rules.
The purpose is:
to initialize Espresso-Intents before each test annotated with
@Testand releases Espresso-Intents after each test run. The following code snippet is an example of anIntentsTestRule:
@Rule
public IntentsTestRule<MyActivity> intentsTestRule =
        new IntentsTestRule<>(MyActivity.class);
Alternatively,
you can use
ActivityTestRuleinstead ofIntentsTestRuleand then in your@Beforeand@Aftermanually callIntents.init()andIntents.release()respectively.
@Override
protected void afterActivityLaunched() {
    Intents.init();
    super.afterActivityLaunched();
}
@Override
protected void afterActivityFinished() {
    super.afterActivityFinished();
    Intents.release();
}
And the purpose of Espresso-intents is
to enable validation and stubbing of Intents sent out by the application under test. It’s like Mockito, but for Android Intents.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With