Sign in Go Pro

Android Model-View-ViewModel Pattern

Testing the UI with Espresso

This lesson is for PRO members.

Upgrade today to get access to all the PRO lessons.

Unlock this lesson
Autoplay

Previous

About

In this final lesson, we'll round off our MVVM Tip Calculator Application with a simple Espresso test that calculates a tip, saves it, and then loads it again, validating all of the outputs along the way.

Key concepts in this lesson that you will learn:

  • How to create and run an Espresso test that interacts with your applications, Floating Action Buttons, OptionsMenus, TextViews, EditTexts and RecyclerViews.
  • You'll also learn how to check values in each of these using ViewAssertions and simulate user interaction with them using ViewActions.

Instructor

Links

Comments

Great explaination. I still doesn't get the testing parts, but overall I could understand how to implement MVVM myself. Thank you.

Thank you! I can recommend a few additional resources for testing with Espresso.

Espresso is a larger topic. We have a few courses here dedicated to various aspects of it:
* UI Testing w/ Espresso and TDD Espresso - These both will build on the fundamentals of using Espresso and Test Driven Development w/ Espresso
* Espresso Test Recorder - The test recorder is kind of neat as you get started with Espresso, because the tooling actually builds a test for you as you exercise the app.
* Espresso Idling Resource - As you start using Espresso more, you'll get into testing more advanced operations like network requests and other long running operations. This course will help you learn how to wait on those operations in your Espresso tests.

We also have a course around Mockito, which I covered briefly in earlier lessons for testing the ViewModel and Model.

* Mockito

I hope that helps on the testing parts!

Cheers!

How you keep preview while typing code.

Hi Sattha,

The Layout Preview tool window appears only for a layout file, which is open for editing and currently has focus. You'll notice that it disappears when we start typing inside of our espresso test and reappears when we set focus on the layout file.

>
You need to go PRO to post comments.

Lessons in Android Model-View-ViewModel Pattern