Putting it all together
Let's add some more functionality to our calculator example. For instance, let's add a login screen and test the whole functionality:
In this case, when we provide the correct login and password details, we will proceed to the next screen, to our calculator. What we want to test is whether the transition works and how we can continue testing on multiple activities.
Imagine we have implemented the following checks on our application logic to check whether an e-mail ID and password are valid (although that does not necessarily mean they are correct):
We can add many unit tests to these methods, but let's just add few of them and focus on UI tests:
With regard to UI tests, first of all let's add some simple tests that will validate that an error is shown if either the username or password is invalid.
When we press the login button, we check for the validity and then for the correctness of the username and password; if something goes wrong, we show an error.
To show...