Android unit-testing support
September 15th, 2010 by Eugene KudelevskyWith 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.

November 8th, 2010 at 12:37 pm
Hi,
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?
November 9th, 2010 at 3:15 am
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.
May 21st, 2012 at 12:25 pm
How does this work in IntelliJ 11? Screens are very different when creating a module.:)
Thanks
Cam
May 22nd, 2012 at 6:31 am
@Cam of course, it works in IDEA 11. If something doesn’t work for you, please create an issue in our tracker
December 16th, 2012 at 12:46 pm
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.
February 22nd, 2013 at 1:40 pm
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:\Workspaces\IntelliJ12\application
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:\Workspaces\IntelliJ12\application\data