Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Screen Robots
@brwngrldev
UI Tests in Espresso
1. User Interface Testing
2. Espresso
3. Screen Robots
Agenda
@brwngrldev
UI Testing
@brwngrldev
UI element
UI Testing
@brwngrldev
UI Testing
@brwngrldev
Espresso
• Framework
• View Matchers
• View Assertions
• View Actions
@brwngrldev
Usage
@brwngrldev
Usage
@brwngrldev
Usage
@brwngrldev
@Test
public void shouldProceedWithLoginWhenValid () {
onView( withId( R.id.login_username_entry ) )
.perform( typeText( T...
@Test
public void shouldProceedWithLoginWhenValid () {
onView( withId( … ) )
.perform( typeText( … ) );
onView( withId( … ...
@Test
public void shouldProceedWithLoginWhenValid () {
< let’s do better />
}
@brwngrldev
@brwngrldev
@Test
public void shouldProceedWithLoginWhenValid () {
}
@brwngrldev
@Test
public void shouldProceedWithLoginWhenValid () {
withRobot( LoginScreenRobot.class )
}
@brwngrldev
@Test
public void shouldProceedWithLoginWhenValid () {
withRobot( LoginScreenRobot.class )
.callLogin( TEST_EMAIL, TEST_PA...
@Test
public void shouldProceedWithLoginWhenValid () {
withRobot( LoginScreenRobot.class )
.callLogin( TEST_EMAIL, TEST_PA...
@brwngrldev
Just 3 lines
of code!
public LoginScreenRobot callLogin (String username, String password)
{
}
@brwngrldev
Screen Robot
public LoginScreenRobot callLogin (String username, String password)
{
return enterTextIntoView ( R.id.login_username_entr...
public LoginScreenRobot callLogin (String username, String password)
{
return enterTextIntoView ( R.id.login_username_entr...
public LoginScreenRobot callLogin (String username, String password)
{
return enterTextIntoView ( R.id.login_username_entr...
@brwngrldev
@brwngrldev
Test Scenarios
• Login with valid credentials
• Login with invalid credentials
• Login with bad server respons...
Summary
Screen Robots
User Interface Testing
Espresso
@brwngrldev
Thanks!
@brwngrldev
+AnnyceDavis
www.adavis.info
Upcoming SlideShare
Loading in …5
×

of

Screen Robots: UI Tests in Espresso Slide 1 Screen Robots: UI Tests in Espresso Slide 2 Screen Robots: UI Tests in Espresso Slide 3 Screen Robots: UI Tests in Espresso Slide 4 Screen Robots: UI Tests in Espresso Slide 5 Screen Robots: UI Tests in Espresso Slide 6 Screen Robots: UI Tests in Espresso Slide 7 Screen Robots: UI Tests in Espresso Slide 8 Screen Robots: UI Tests in Espresso Slide 9 Screen Robots: UI Tests in Espresso Slide 10 Screen Robots: UI Tests in Espresso Slide 11 Screen Robots: UI Tests in Espresso Slide 12 Screen Robots: UI Tests in Espresso Slide 13 Screen Robots: UI Tests in Espresso Slide 14 Screen Robots: UI Tests in Espresso Slide 15 Screen Robots: UI Tests in Espresso Slide 16 Screen Robots: UI Tests in Espresso Slide 17 Screen Robots: UI Tests in Espresso Slide 18 Screen Robots: UI Tests in Espresso Slide 19 Screen Robots: UI Tests in Espresso Slide 20 Screen Robots: UI Tests in Espresso Slide 21 Screen Robots: UI Tests in Espresso Slide 22 Screen Robots: UI Tests in Espresso Slide 23 Screen Robots: UI Tests in Espresso Slide 24 Screen Robots: UI Tests in Espresso Slide 25 Screen Robots: UI Tests in Espresso Slide 26
Upcoming SlideShare
Creating Gradle Plugins - GR8Conf US
Next
Download to read offline and view in fullscreen.

0 Likes

Share

Download to read offline

Screen Robots: UI Tests in Espresso

Download to read offline

Often when writing tests with Espresso you find a lot of onView, withId, perform calls scattered throughout your test methods. This takes away from the simplicity of the test, tends to be verbose and also litters resource ids everywhere. There's got to be a better way, right? Yes, there is...Screen Robots. In this presentation you will learn how to take advantage of the Screen Robot abstraction technique.

Related Books

Free with a 30 day trial from Scribd

See all

Related Audiobooks

Free with a 30 day trial from Scribd

See all
  • Be the first to like this

Screen Robots: UI Tests in Espresso

  1. 1. Screen Robots @brwngrldev UI Tests in Espresso
  2. 2. 1. User Interface Testing 2. Espresso 3. Screen Robots Agenda @brwngrldev
  3. 3. UI Testing @brwngrldev UI element
  4. 4. UI Testing @brwngrldev
  5. 5. UI Testing @brwngrldev
  6. 6. Espresso • Framework • View Matchers • View Assertions • View Actions @brwngrldev
  7. 7. Usage @brwngrldev
  8. 8. Usage @brwngrldev
  9. 9. Usage @brwngrldev
  10. 10. @Test public void shouldProceedWithLoginWhenValid () { onView( withId( R.id.login_username_entry ) ) .perform( typeText( TEST_EMAIL ) ); onView( withId( R.id.login_password_entry ) ) .perform( typeText( TEST_PASSWORD ) ); onView( withId( R.id.login_button ) ) .perform( click() ); intended( hasComponent( hasShortClassName( PACKAGE_NAME ) ) ); } @brwngrldev
  11. 11. @Test public void shouldProceedWithLoginWhenValid () { onView( withId( … ) ) .perform( typeText( … ) ); onView( withId( … ) ) .perform( typeText( … ) ); onView( withId( … ) ) .perform( click() ); … } @brwngrldev
  12. 12. @Test public void shouldProceedWithLoginWhenValid () { < let’s do better /> } @brwngrldev
  13. 13. @brwngrldev
  14. 14. @Test public void shouldProceedWithLoginWhenValid () { } @brwngrldev
  15. 15. @Test public void shouldProceedWithLoginWhenValid () { withRobot( LoginScreenRobot.class ) } @brwngrldev
  16. 16. @Test public void shouldProceedWithLoginWhenValid () { withRobot( LoginScreenRobot.class ) .callLogin( TEST_EMAIL, TEST_PASSWORD ) } @brwngrldev
  17. 17. @Test public void shouldProceedWithLoginWhenValid () { withRobot( LoginScreenRobot.class ) .callLogin( TEST_EMAIL, TEST_PASSWORD ) .checkIsLoggedIn(); } @brwngrldev
  18. 18. @brwngrldev Just 3 lines of code!
  19. 19. public LoginScreenRobot callLogin (String username, String password) { } @brwngrldev Screen Robot
  20. 20. public LoginScreenRobot callLogin (String username, String password) { return enterTextIntoView ( R.id.login_username_entry, username ) } @brwngrldev Screen Robot
  21. 21. public LoginScreenRobot callLogin (String username, String password) { return enterTextIntoView ( R.id.login_username_entry, username ) .enterTextIntoView ( R.id.login_password_entry, password ) } @brwngrldev Screen Robot
  22. 22. public LoginScreenRobot callLogin (String username, String password) { return enterTextIntoView ( R.id.login_username_entry, username ) .enterTextIntoView ( R.id.login_password_entry, password ) .clickOkOnView( R.id.login_button ); } @brwngrldev Screen Robot
  23. 23. @brwngrldev
  24. 24. @brwngrldev Test Scenarios • Login with valid credentials • Login with invalid credentials • Login with bad server response • Changing the slide language • Verifying the correctness of the slide content • Entering content into a text slide
  25. 25. Summary Screen Robots User Interface Testing Espresso @brwngrldev
  26. 26. Thanks! @brwngrldev +AnnyceDavis www.adavis.info

Often when writing tests with Espresso you find a lot of onView, withId, perform calls scattered throughout your test methods. This takes away from the simplicity of the test, tends to be verbose and also litters resource ids everywhere. There's got to be a better way, right? Yes, there is...Screen Robots. In this presentation you will learn how to take advantage of the Screen Robot abstraction technique.

Views

Total views

580

On Slideshare

0

From embeds

0

Number of embeds

3

Actions

Downloads

6

Shares

0

Comments

0

Likes

0

×