I am using Android Studio 0.2.4, but I assume this question can pertain to IntelliJ in general. My tests are under src/instrumentTest/java and all extend AndroidTestCase. When I run all the tests (say by right clicking on the source folder and clicking "Run...") the tests run just fine on the Android emulator as Android Tests (as seen under the Run/Debug Configurations).
But if I try to run a single test method or test class the same way (right click on the method and click "Run..."), the test runs as a normal JUnit test not on the emulator, which of course fails (stack trace below). Even if I try to create a new Run Configuration, I see no way a creating anything other than a JUnit configuration.
From the IDE, how do run a test method or test class as an Android Test?
Exception in thread "main" java.lang.NoClassDefFoundError: junit/textui/ResultPrinter
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:188)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:113)
Caused by: java.lang.ClassNotFoundException: junit.textui.ResultPrinter
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
... 3 more