Solution 1 :
I used -Pandroid.testInstrumentationRunnerArguments.notPackage=com.example.foo option in gradle test run command. It works!
Source:
https://medium.com/stepstone-tech/exploring-androidjunitrunner-filtering-options-df26d30b4f60
Problem :
https://github.com/googlesamples/android-testing-templates/tree/master/AndroidTestingBlueprint documentation tells you how to include a class while test run. Example
./gradlew app:connectedAndroidTest -Pandroid.testInstrumentationRunnerArguments.class=com.example.android.testing.blueprint.ui.espresso.EspressoTest
Is there a command which can be used for gradle instrumentation test run to exclude a package using command line?