Closed FisherKK closed 7 years ago
To be honest, I have not tried our size-specific tasks with a test runner from the support library (only with a default runner provided by the Android SDK).
Probably, using a support library runner, you need to specify parameters differently. But it should still be possible with spoon. instrumentationArgs
So this is my Runner:
public class MyAppTestRunner extends AndroidJUnitRunner {
@Override
public Application newApplication(ClassLoader cl, String className, Context context)
throws InstantiationException, IllegalAccessException, ClassNotFoundException {
return super.newApplication(cl, MyAppTestApplication.class.getName(), context);
}
}
And like I said I am using this annotation:
@RunWith(AndroidJUnit4.class)
So according to documentation of AndroidJUnitRunner, which I am using, I have to add parameter like this:
Running a specific test size i.e. annotated with SmallTest or MediumTest or LargeTest: adb shell am instrument -w -e size [small|medium|large] com.android.foo/android.support.test.runner.AndroidJUnitRunner
Spoon by default uses this command:
03:51:04 I/RemoteAndroidTest: Running am instrument -w -r com.MyApp.debug1.test/com.MyApp.instrumentation.config.MyAppTestRunner on Nexus_5_API_23 [emulator-5554]
So what I am missing according to documentation is:
-e size small
After -r
and before com.MyApp.debug1.test/com.MyApp.instrumentation.config.MyAppTestRunner
.
So I did that:
spoon {
(...)
instrumentationArgs = ["size=small"]
(...)
}
And after this my spoon run command looks like that:
03:54:37 I/RemoteAndroidTest: Running am instrument -w -r -e size small com.MyApp.debug1.test/com.MyApp.instrumentation.config.MyAppTestRunner
Yet:
Total tests 0
Which classes are you using then? Maybe I can make it work for myself.
Edit: maybe I am doing something wrong. More there: http://stackoverflow.com/questions/41446892/how-to-run-instrumentation-smalltests-from-terminal
./gradlew spoonSmall
works. I probably got confused somewhere during implementation. After I gave it another look today everyhing worked fine.
Furthermore I have implemented my own annotation and I am passing it to:
instrumentationArgs=["annotation=<my.annotation.package.annotationName>"]
and it works too so thanks for spoon :)
This can be closed I guess.
All my tests uses annotation @Test. I need to create subset of tests (I have like 400-500 tests in various packages and I don't want to copy them to new package) - so I decided to use @SmallTest annotation in order to run them with
./gradlew spoonSmall
.I use this dependency:
And above my java class containing test I have:
What I did is:
./gradlew spoonSmall
What I expected: Spoon will run only one test.
What was result: Spoon didn't pick any test for me.
Am I doing something wrong?