With IntelliJ IDEA you can generate and run unit tests for your Android applications using Android Testing Framework
.
Unit tests are stored in a dedicated module related to the target module that is going to be tested. Each module requires a separate test module. To execute unit tests,
IntelliJ IDEA provides an Android-specific run configuration.
In this topic:
- Select File | New | Module from the main menu, or New | Module from the context menu of the Project tool window.
- On the first page of the New Module wizard that opens, select Test Module.
-
On the next step of the wizard, specify the module name, the location of the
.imlmodule file and the content root of the module. - From the Tested module drop-down list, select the module against which you are going to run unit tests. Click Finish.
IntelliJ IDEA creates a module with the specified name and a stub test class for your main activity with the default name <main activity class name>.test.
Complete the stub and populate
A default Android run configuration is created automatically.
-
Specify the tests that you want to run. Do one of the following:
- To run a single test, open it in the editor and select Run | Android Test from the context menu. IntelliJ IDEA creates an Android Test temporary run configuration.
- To run all tests in a class or an entire test module, create an Android Test run/debug configuration.
- Select a run/debug configuration from the drop-down list on the main toolbar and start the test according to it.
- Monitor the test execution and view test results in the Test Runner tab of the Run tool window.
See Also
Procedures:
- Getting Started with Android Development
- Adding Modules to a Project
- Running and Debugging Android Applications
- Android
Reference:
Concepts:
External Links: