Everytime I run "gradlew test" on terminal in Android Studio, ALL my tests (stored in app\src\androidTest\java\path\to\package") are running.
dependencies to compile tests in app/build.gradle are:
androidTestCompile 'junit:junit:4.10'
androidTestCompile 'org.robolectric:robolectric:2.1.+'
androidTestCompile 'com.squareup:fest-android:1.0.+'
androidTestCompile "org.mockito:mockito-all:1.9.5"
I'm new in JUnit and Robolectric, also I've got a "default" TestRunner:
public class MyTestRunner extends RobolectricTestRunner {
public MyTestRunner (Class<?> testClass) throws InitializationError {
super(testClass);
}
@Override
protected AndroidManifest getAppManifest(Config config) {
String manifestProperty = System.getProperty("android.manifest");
if (config.manifest().equals(Config.DEFAULT) && manifestProperty != null) {
String resProperty = System.getProperty("android.resources");
String assetsProperty = System.getProperty("android.assets");
return new AndroidManifest(Fs.fileFromPath(manifestProperty), Fs.fileFromPath(resProperty),
Fs.fileFromPath(assetsProperty));
}
return super.getAppManifest(config);
}
}
Every ClassTest.java is annotated by @RunWith(MyTestRunner.class)
.
How can I run only a few tests? E.g. only one specific test or all tests in one specific class / one specific package?
And maybe there's a way to do all this by Android Studio GUI instead of the Terminal? (would be nice to know ;) )