Android Instrumentation Test Runner: How to filter multiple test annotations

1.4k views Asked by At

The documentation for instrument is clear on how to filter a single test annotation from a test run:

Filter test run to tests without given annotation: adb shell am instrument -w -e notAnnotation com.android.foo.MyAnnotation com.android.foo/android.test.InstrumentationTestRunner

(from https://developer.android.com/reference/android/test/InstrumentationTestRunner.html)

Is it possible to filter multiple annotations? I have not found a syntax that works thus far. I have tried:

  • adb shell am instrument -w -e notAnnotation com.android.foo.MyAnnotation -e notAnnotation com.android.foo.AnotherAnnotation com.android.foo/android.test.InstrumentationTestRunner
  • adb shell am instrument -w -e notAnnotation com.android.foo.MyAnnotation,com.android.foo.AnotherAnnotation com.android.foo/android.test.InstrumentationTestRunner
  • adb shell am instrument -w -e notAnnotation com.android.foo.MyAnnotation com.android.foo.AnotherAnnotation com.android.foo/android.test.InstrumentationTestRunner
  • adb shell am instrument -w -e notAnnotation "com.android.foo.MyAnnotation","com.android.foo.AnotherAnnotation" com.android.foo/android.test.InstrumentationTestRunner

and probably others that I've forgotten, thus far to no avail.

Anyone know how to do this?

1

There are 1 answers

0
Alex P. On

You should be using AndroidJUnitRunner anyway:

Filter test run to tests without any of a list of annotations:

adb shell am instrument -w -e notAnnotation com.android.foo.MyAnnotation,com.android.foo.AnotherAnnotation com.android.foo/android.support.test.runner.AndroidJUnitRunner