AI-171.4163606, JRE 1.8.0_152-release-884-b01x64 JetBrains s.r.o, OS Mac OS X(x86_64) v10.12.5 unknown, screens 1680x1050, 2560x1440
I can create the following tests inside an inner class which lives in another class or interface, like this:
public interface SampleTest {
@Test void sampleTest();
public static final class DefaultImpls { @Test public static void sampleTest() { // default impl here } } }
or
public class OuterClass { public static final class InnerClass { @Test public static void innerTest() { // test impl here } } }
If I create these as JVM tests, everything works perfectly. If they are Android instrumentation tests, I cannot run them from Android Studio. For example, if I try to run the second example, Android Studio generates the following adb command:
adb shell am instrument -w -r -e debug false -e class com.example.OuterClass.InnerClass#innerTest com.example.test/android.support.test.runner.AndroidJUnitRunner
Notice that it's using OuterClass.InnerClass rather than OuterClass$InnerClass. This seems like a definite bug to me.
If I manually change the adb command that was run, I start running into shell escaping problems, so watch out for that if you're trying to reproduce this issue. To get it to really work, I needed to run:
Description
AI-171.4163606, JRE 1.8.0_152-release-884-b01x64 JetBrains s.r.o, OS Mac OS X(x86_64) v10.12.5 unknown, screens 1680x1050, 2560x1440
I can create the following tests inside an inner class which lives in another class or interface, like this:
public interface SampleTest {
@Test
void sampleTest();
public static final class DefaultImpls {
@Test
public static void sampleTest() {
// default impl here
}
}
}
or
public class OuterClass {
public static final class InnerClass {
@Test
public static void innerTest() {
// test impl here
}
}
}
If I create these as JVM tests, everything works perfectly. If they are Android instrumentation tests, I cannot run them from Android Studio. For example, if I try to run the second example, Android Studio generates the following adb command:
adb shell am instrument -w -r -e debug false -e class com.example.OuterClass.InnerClass#innerTest com.example.test/android.support.test.runner.AndroidJUnitRunner
Notice that it's using OuterClass.InnerClass rather than OuterClass$InnerClass. This seems like a definite bug to me.
If I manually change the adb command that was run, I start running into shell escaping problems, so watch out for that if you're trying to reproduce this issue. To get it to really work, I needed to run:
adb shell 'am instrument -w -r -e debug false -e class com.example.OuterClass\$InnerClass#innerTest com.example.test/android.support.test.runner.AndroidJUnitRunner'
Notice the ' around am ... and the \$.
For context on how this issue was discovered, see