Menu
All the same Lynda.com content you know and love. Espresso is the tool of choice for many Android developers, who need to test the logic and UI of their applications. Join instructor Chiu-Ki Chan to learn the essentials of Android Espresso for UI testing. Effective Android Testing for Mobile Developers. With Chiu-Ki Chan.
Unit tests are the fundamental tests in your app testing strategy. By creating and running unittests against your code, you can easily verify that the logic of individual units is correct.Running unit tests after every build helps you toquickly catch and fix software regressions introduced by code changes to your app.A unit test generally exercises the functionality of the smallest possible unit of code (whichcould be a method, class, or component) in a repeatable way. You should build unit tests when youneed to verify the logic of specific code in your app. For example, if you are unit testing aclass, your test might check that the class is in the right state. Typically, the unit of codeis tested in isolation; your test affects and monitors changes to that unit only.You can use dependency providers like Robolectric or ato isolate your unit from its dependencies.Note: Unit tests are not suitable for testingcomplex UI interaction events.
Instead, you should use the UI testing frameworks, as described in.For testing Android apps, you typically create these types of automated unit tests:. Local tests: Unit tests that run on your local machineonly.
These tests are compiled to run locally on the Java Virtual Machine (JVM)to minimize execution time. If your tests depend on objects in the Androidframework, we recommend using Robolectric. For tests that depend on yourown dependencies, use mock objects to emulate your dependencies' behavior. Instrumented tests: Unit tests that run on an Android device or emulator.These tests have access to instrumentation information, such as thefor the app under test.Use this approach to run unit tests that have complex Android dependencies that require a morerobust environment, such as Robolectric.The lessons in this class teach you how to build these types of automated unit tests.
![For For](/uploads/1/2/5/6/125641100/481604021.jpg)
Lessons Learn how to build unit tests that run on your local machine. Learn how to build unit tests that run on an Android device or emulator. Additional resourcesFor more information about using Espresso in Android tests, consult thefollowing resources. Samples.Shows how to implement instrumented unit tests.Codelabs.Content and code samples on this page are subject to the licenses described in the. Java is a registered trademark of Oracle and/or its affiliates.