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? - Android Tutorial
From the course: Advanced Android Espresso Testing
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
App: Cat Names1m 28s
-
How intents are used5m 6s
-
Incoming intents: Empty4m 20s
-
Incoming intents: Activity rule2m 45s
-
Incoming intents: Known theme2m 19s
-
Incoming intents: Loading string2m 25s
-
Incoming intents: Unknown theme4m 34s
-
Outgoing intents: Launch activity4m 14s
-
Outgoing intents: Verify intent5m 1s
-
Outgoing intents: How to match?5m 5s
-
Stubbing: Intending1m 16s
-
Stubbing: ActivityResult4m 52s
-
-
-
-