Show navigation Hide navigation

Testing Your Android Activity

Dependencies and prerequisites

  • Android 2.2 (API Level 8) or higher.

You Should Also Read

You should be writing and running tests as part of your Android application development cycle. Well-written tests can help you to catch bugs early in development and give you confidence in your code.

A test case defines a set of objects and methods to run multiple tests independently from each other. Test cases can be organized into test suites and run programmatically, in a repeatable manner, with a test runner provided by a testing framework.

The lessons in this class teaches you how to use the Android's custom testing framework that is based on the popular JUnit framework. You can write test cases to verify specific behavior in your application, and check for consistency across different Android devices. Your test cases also serve as a form of internal code documentation by describing the expected behavior of app components.

Lessons

Setting Up Your Test Environment
Learn how to create your test project.
Creating and Running a Test Case
Learn how to write test cases to verify the expected properties of your Activity, and run the test cases with the Instrumentation test runner provided by the Android framework.
Testing UI Components
Learn how to test the behavior of specific UI components in your Activity.
Creating Unit Tests
Learn how to how to perform unit testing to verify the behavior of an Activity in isolation.
Creating Functional Tests
Learn how to perform functional testing to verify the interaction of multiple Activities.