Search code examples
androidadbandroid-espressoandroid-instrumentation

How can I run both '@SmallTest' and '@MediumTest' and not '@LargeTest'?


Details:

I want to be able to run all @SmallTest and @MediumTest tests while ignoring @LargeTest tests.

It looks like Android ADB instrumentation commands support negation. For example, you can negate annotation like notAnnotation but I do not see a notSize for size.

Ideally it would be nice to have something similar to: adb shell am instrument -w -e notSize large com.android.foo/android.support.test.runner.AndroidJUnitRunner.

I rather not create custom annotations and then be forced to re-annotate all of my tests.

I have tried the following:

  • Tried notSize:
    • adb shell am instrument -w -e notSize large com.android.foo/android.support.test.runner.AndroidJUnitRunner
  • 2 size parameters:
    • adb shell am instrument -w -e size small -e size medium com.android.foo.MyAnnotation com.android.foo/android.support.test.runner.AndroidJUnitRunner

References


Solution

  • Using notAnnotation and specifying the fully qualified path of LargeTest:

    adb shell am instrument -w -e notAnnotation android.support.test.filters.LargeTest com.android.foo/android.support.test.runner.AndroidJUnitRunner