Home Intended vs Intending in Espresso.
Post
Cancel

Intended vs Intending in Espresso.

Test your intents using intended, intending when to use what.

You might be already aware of Espresso-Intents which is an extension of Espresso used for testing Intents.The espresso intents basically offers two methods for intent validation.

Note:
If your not using IntentsTestRule but using ActivityTestRule or ActivityScenario, Please make sure you call Intents.init() and Intents.release() before and after testing the intents.

1.Intended():

This method is used to verify that the given intent is already seen, which means you cannot use it to test an intent that is going to launch, reason being verification does not have to occur in the same order as the intents were sent(If you have to then try using espresso idling resource).

2.Intending():

The main use case of using intending, is when you start activity for result. If you have ever used mockito framework, it is similar to when that is once you start activity for result then respond with this result.One of the best thing is it can be used to verify external activities like contact picker or camera etc. Intending can be used to verify the launching intent also.

More reading:

Espresso-Intents

This post is licensed under CC BY 4.0 by the author.