Android unit-testing support

With IntelliJ IDEA X you can write unit tests for your Android application using Android Testing Framework. Android unit tests are located in a separate test module, so first you need to add it (i.e. named tests) to your project, which must already contain an Android module (or module with Android facet) (i.e. named MyAndroidApp). Then, specify this tested module:

IntelliJ IDEA will automatically create a sample test class for your main activity (i.e. MyActivityTest). It’s handy that you can launch tests directly from editor. Note that it is important to choose an item with Android-specific icon for launching tests by Android Tests run configuration rather than using a default JUnit configuration:

Also, after adding a test module to project, IntelliJ IDEA automatically creates run configuration for launching all tests in module:

Note, that scope of a dependency between Test module and Application module should be Provided.

Discover more