Test That App Launches Another App In Android
I have a very simple activity, that redirects the user to the app's Play Store page, when the button is clicked: public class MyActivity extends AppCompatActivity { private sta
Solution 1:
I would click the button, then use:
intended(allOf(
hasAction(Intent.ACTION_VIEW),
hasData("https://play.google.com/store/apps/...your app...")
))
Solution 2:
I would suggest a slightly different question - is it you app's job to verify that? You'd be testing not your own app but Android OS and Google's Play Store App.
The way I've been approaching it is by being explicit about the boundaries, and aware of the possible scenarios.
What I mean by that is, extract the Intent
manipulation and invocation logic into a thin service (that's the being explicit about boundaries part) and test your Activity
correctly interacts with it (by constructing the Intent
appropriately).
The part about possible scenarios is being aware of what can happen. For example what does your app do (if anything) if the user doesn't have Play Store on their phone.
Post a Comment for "Test That App Launches Another App In Android"