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:
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:
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 instrumentcommand.Hope this make sense.