I'm using maven for building, running and instrumentation testing my Android applications. Android testing framework has three different test scopes @SmallTest, @MediumTest and @LargeTest and android-maven-plugin has ability to select test scope via testTestSize or test/testSize parameter. This parameter can be one of small|medium|large
and can run your tests from related scope.
But what can i do if i want to run small and medium tests simultaneously, not only small or not only medium? Any solution for this problem exists?
This is how Android SDK is designed and supposed to work at the moment, according to InstrumentationTestRunner API doc:
Running all small tests: adb shell am instrument -w -e size small com.android.foo/android.test.InstrumentationTestRunner
Running all medium tests: adb shell am instrument -w -e size medium com.android.foo/android.test.InstrumentationTestRunner
Running all large tests: adb shell am instrument -w -e size large com.android.foo/android.test.InstrumentationTestRunner
Even if you use the plain adb command to run your test, you have to use two process to run small and medium test separately, one after another. Android Maven Plugin is just another wrapper of the adb command, so there is no way to alter the default behaviour via android-maven-plugin configuration AFAIK.
If you read the InstrumentationTestRunner API doc more carefully, you will note that there is an interesting command usage:
Filter test run to tests with given annotation: adb shell am instrument -w -e annotation com.android.foo.MyAnnotation com.android.foo/android.test.InstrumentationTestRunner
If used with other options, the resulting test run will contain the union of the two options. e.g. "-e size large -e annotation com.android.foo.MyAnnotation" will run only tests with both the LargeTest and "com.android.foo.MyAnnotation" annotations.
The annotation configuration is added as experimental API (marked as @hide, for more details check out this version history), and hasn't been documented in am instrument options list. Theoretically you can create your own annotation class (see SmallTest.java as example), mark all @MediumTest along with your @CustomizedTest and use both -e size and -e annotation to achieve what you want: run union tests from two annotations simultaneously, all in one command.
Unfortunately, android-maven-plugin is not support annotation configuration, see plugin documentation and latest source code. A possible workaround is to use exec-maven-plugin run the plain adb shell am instrument
command.
Hope this make sense.