From the course: Advanced Android Espresso Testing

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Outgoing intents: How to match?

Outgoing intents: How to match? - Android Tutorial

From the course: Advanced Android Espresso Testing

Start my 1-month free trial

Outgoing intents: How to match?

- [Instructor] We called hasExtra to match the intent extra. How did I know I should use hasExtra? What if we want to match the activity being launched? What if we want to verify the idea's activity is the one that's getting launched? We can pour through the documentation, but that's a lot of functions, and it's a bit hard to figure out which one works best. Instead, we can create an intent matcher that measures all intents and examine the intent that got intercepted. Let's do that. As a starting point, we will take a look at the any intent intent matcher that comes with the Espresso-Intents Library. Go to the end of the punnyIntended function and add a new line with IntentMatches.anyIntent. Command click to take a look at the code. Here you can see that it matches all intents because on line 54 the match safely function simply returns true. Copy and paste all of it into our test. It asked us to convert from Java to Kotlin. Let's do that. Then go back to line 46 and delete it. Next…

Contents