Created
April 5, 2018 02:57
-
-
Save AdamMc331/8beb16c73d7deefe870fc25947728bf1 to your computer and use it in GitHub Desktop.
Small gist used to answer a followup question from the NY Android Meetup.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Any actions that occur on the Registration screen, successful or otherwise, should only deal with the RegistrationRobot. | |
// If you move to a new screen, the robot itself doesn't need to be aware of that. Your test can create the new robot. | |
// As seen in this example, where we move the flow over to a ProfileRobot after clicking register. | |
@Test | |
fun testSuccessfulRegistration() { | |
RegistrationRobot() | |
.firstName("Adam") | |
.lastName("McNeilly") | |
.email("amcneilly@okcupid.com") | |
.phone("1234567890") | |
.register() | |
ProfileRobot() | |
.assertFullNameDisplay("Adam McNeilly") | |
.assertEmailDisplay("amcneilly@okcupid.com") | |
.assertPhoneDisplay("(123)-456-7890") | |
} | |
// Following the above comment, we can see that we don't have to worry now when we want to test a negative case, because | |
// that sort of thing is still handled by the RegistrationRobot. | |
@Test | |
fun testMissingEmailError() { | |
RegistrationRobot() | |
.firstName("Adam") | |
.lastName("McNeilly") | |
.phone("1234567890") | |
.register() | |
.assertEmailError("Must enter an email address.") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Actually, attempting method 3 in a larger application quickly shows its downfalls. There's no guarantee that a
register()
type of method that transitions to another robot always returns the same robot. I'll stick to the method you mentioned, thanks again! Some lessons learned: