Testing Android Applications
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:
To create a module for Android unit tests
- 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.
To run unit tests for an Android application
- Specify the tests that you want to run. Do one of the following:
- 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.