Issue
Scenario:
- The user starts the app
- The user goes to the "CreateAccountActivity"
- In order to use the application the user has to enter the email and a password
The user clicks "create" which switches to the next activity.
@Test public void createAccountAndLogIn() { onView(withId(R.id.login_create)).perform(click()); onView(withId(R.id.create_email)).perform(clearText(),typeText("[email protected]")); onView(withId(R.id.create_pass)).perform(clearText(),typeText("pass")); onView(withId(R.id.create_pass_repeat)).perform(clearText(),typeText("pass")); onView(withId(R.id.create_create_button)).perform(click()); }
How to check, after the last line, if the new "MainActivity" was launched?
Solution
It is possible using ActivityLifecycleMonitor ... However it will not be a "black box" approach that you are looking for.
If you want to go full black box, asserting the view on the next activity should be sufficient enough to pass a test.
Here is the same question that has more detailed explanation.
Is there any way to know if an activity has been started with Espresso?
Answered By - Be_Negative
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.