IntelliJ IDEA 2016.1 Help

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

  1. Select File | New | Module from the main menu, or New | Module from the context menu of the Project tool window.
  2. On the first page of the New Module wizard that opens, select Test Module.
  3. On the next step of the wizard, specify the module name, the location of the .iml module file and the content root of the module.
  4. 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

  1. Specify the tests that you want to run. Do one of the following:
  2. Select a run/debug configuration from the drop-down list on the main toolbar and start the test according to it.
  3. Monitor the test execution and view test results in the Test Runner tab of the Run tool window.

See Also

Last modified: 13 July 2016