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.

Comments below can no longer be edited.

6 Responses to Android unit-testing support

  1. Avatar

    p-daddy says:

    November 8, 2010


    I just purchased the ultimate version of intellij and I’m still not quite understanding how to add the android testing framework to my android project

    Specifically, looking at your screenshots above, there is a window (the picture is called test-module) where you specify the the SDK and you can then (in the same window) specify “Application”, “Library” or “Test”.

    When I create a new module within my Android application, I don’t see this option (“application”, “library”, or “test”)

    Is there a more step-by-step guide on how to set up testing for android?

  2. Avatar

    yole says:

    November 9, 2010

    The Android testing support is a new feature of IntelliJ IDEA X, which is currently in development and available as Early Access Preview. It’s not available in IntelliJ IDEA 9.

  3. Avatar

    Cam says:

    May 21, 2012

    How does this work in IntelliJ 11? Screens are very different when creating a module.:)



  4. Avatar

    Eugene Kudelevsky says:

    May 22, 2012

    @Cam of course, it works in IDEA 11. If something doesn’t work for you, please create an issue in our tracker

  5. Avatar

    Evgen says:

    December 16, 2012

    I have a Android maven project could you give me some hints about right way to add Andorid unit-testing to my project? I have IDEA 11.

  6. Avatar

    John Matthews says:

    February 22, 2013

    I am using IDEA 12.0.4 Ultimate and when I use the wizard to create new Android Test Project, it starts to create one and then errors with this:

    The project wasn’t generated by ‘android’ tool.

    Error: No AndroidManifest.xml file found in the main project directory: C:WorkspacesIntelliJ12application

    Not sure why… but the project I am using is a couple of android applications and Java libraries put into one. The error showing the directory isn’t the directory I was pointing to its at C:WorkspacesIntelliJ12applicationdata

Discover more