Created
March 22, 2016 13:59
-
-
Save bholota/5ede7d1083dd3e67e4fb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: spoon-runner/src/main/java/com/squareup/spoon/SpoonDeviceRunner.java | |
IDEA additional info: | |
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
<+>UTF-8 | |
=================================================================== | |
--- spoon-runner/src/main/java/com/squareup/spoon/SpoonDeviceRunner.java (revision 0e7361ea1c2926d3953a37a4f62357bc94dde3e2) | |
+++ spoon-runner/src/main/java/com/squareup/spoon/SpoonDeviceRunner.java (revision ) | |
@@ -61,6 +61,7 @@ | |
private final List<String> instrumentationArgs; | |
private final String className; | |
private final String methodName; | |
+ private final String packageName; | |
private final IRemoteAndroidTestRunner.TestSize testSize; | |
private final File work; | |
private final File junitReport; | |
@@ -90,7 +91,7 @@ | |
SpoonDeviceRunner(File sdk, File apk, File testApk, File output, String serial, boolean debug, | |
boolean noAnimations, int adbTimeout, String classpath, | |
SpoonInstrumentationInfo instrumentationInfo, List<String> instrumentationArgs, | |
- String className, String methodName, IRemoteAndroidTestRunner.TestSize testSize, | |
+ String className, String methodName, String packageName, IRemoteAndroidTestRunner.TestSize testSize, | |
List<ITestRunListener> testRunListeners) { | |
this.sdk = sdk; | |
this.apk = apk; | |
@@ -102,6 +103,7 @@ | |
this.instrumentationArgs = instrumentationArgs; | |
this.className = className; | |
this.methodName = methodName; | |
+ this.packageName = packageName; | |
this.testSize = testSize; | |
this.classpath = classpath; | |
this.instrumentationInfo = instrumentationInfo; | |
@@ -238,13 +240,16 @@ | |
} | |
} | |
- if (!isNullOrEmpty(className)) { | |
+ if (!isNullOrEmpty(packageName)) { | |
+ runner.setTestPackageName(packageName); | |
+ } else if (!isNullOrEmpty(className)) { | |
if (isNullOrEmpty(methodName)) { | |
runner.setClassName(className); | |
} else { | |
runner.setMethodName(className, methodName); | |
} | |
} | |
+ | |
if (testSize != null) { | |
runner.setTestSize(testSize); | |
} | |
Index: spoon-runner/src/main/java/com/squareup/spoon/SpoonRunner.java | |
IDEA additional info: | |
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
<+>UTF-8 | |
=================================================================== | |
--- spoon-runner/src/main/java/com/squareup/spoon/SpoonRunner.java (revision 0e7361ea1c2926d3953a37a4f62357bc94dde3e2) | |
+++ spoon-runner/src/main/java/com/squareup/spoon/SpoonRunner.java (revision ) | |
@@ -54,6 +54,7 @@ | |
private final List<String> instrumentationArgs; | |
private final String className; | |
private final String methodName; | |
+ private final String packageName; | |
private final Set<String> serials; | |
private final String classpath; | |
private final IRemoteAndroidTestRunner.TestSize testSize; | |
@@ -64,7 +65,7 @@ | |
private SpoonRunner(String title, File androidSdk, File applicationApk, File instrumentationApk, | |
File output, boolean debug, boolean noAnimations, int adbTimeoutMillis, Set<String> serials, | |
- String classpath, List<String> instrumentationArgs, String className, String methodName, | |
+ String classpath, List<String> instrumentationArgs, String className, String methodName, String packageName, | |
IRemoteAndroidTestRunner.TestSize testSize, boolean failIfNoDeviceConnected, | |
List<ITestRunListener> testRunListeners, boolean sequential, File initScript, | |
boolean terminateAdb) { | |
@@ -79,6 +80,7 @@ | |
this.instrumentationArgs = instrumentationArgs; | |
this.className = className; | |
this.methodName = methodName; | |
+ this.packageName = packageName; | |
this.classpath = classpath; | |
this.testSize = testSize; | |
this.serials = ImmutableSet.copyOf(serials); | |
@@ -270,7 +272,7 @@ | |
private SpoonDeviceRunner getTestRunner(String serial, SpoonInstrumentationInfo testInfo) { | |
return new SpoonDeviceRunner(androidSdk, applicationApk, instrumentationApk, output, serial, | |
- debug, noAnimations, adbTimeoutMillis, classpath, testInfo, instrumentationArgs, className, | |
+ debug, noAnimations, adbTimeoutMillis, classpath, testInfo, instrumentationArgs, className, packageName, | |
methodName, testSize, testRunListeners); | |
} | |
@@ -287,6 +289,7 @@ | |
private List<String> instrumentationArgs; | |
private String className; | |
private String methodName; | |
+ private String packageName; | |
private boolean noAnimations; | |
private IRemoteAndroidTestRunner.TestSize testSize; | |
private int adbTimeoutMillis = DEFAULT_ADB_TIMEOUT_SEC * 1000; | |
@@ -421,6 +424,11 @@ | |
return this; | |
} | |
+ public Builder setPackageName(String packageName) { | |
+ this.packageName = packageName; | |
+ return this; | |
+ } | |
+ | |
public Builder addTestRunListener(ITestRunListener testRunListener) { | |
checkNotNull(testRunListener, "TestRunListener cannot be null."); | |
testRunListeners.add(testRunListener); | |
@@ -445,7 +453,7 @@ | |
} | |
return new SpoonRunner(title, androidSdk, applicationApk, instrumentationApk, output, debug, | |
- noAnimations, adbTimeoutMillis, serials, classpath, instrumentationArgs, className, | |
+ noAnimations, adbTimeoutMillis, serials, classpath, instrumentationArgs, className, packageName, | |
methodName, testSize, failIfNoDeviceConnected, testRunListeners, sequential, initScript, | |
terminateAdb); | |
} | |
@@ -487,6 +495,10 @@ | |
description = "Test method name to run (must also use --class-name)") // | |
public String methodName; | |
+ @Parameter(names = {"--package-name"}, | |
+ description = "Test package to run (--class-name and --method-name will be ignored)") | |
+ public String packageName; | |
+ | |
@Parameter(names = { "--size" }, converter = TestSizeConverter.class, | |
description = "Only run methods with corresponding size annotation (small, medium, large)") | |
public IRemoteAndroidTestRunner.TestSize size; | |
@@ -591,7 +603,8 @@ | |
.setInitScript(parsedArgs.initScript) | |
.setInstrumentationArgs(parsedArgs.instrumentationArgs) | |
.setClassName(parsedArgs.className) | |
- .setMethodName(parsedArgs.methodName); | |
+ .setMethodName(parsedArgs.methodName) | |
+ .setPackageName(parsedArgs.packageName); | |
if (parsedArgs.serials == null || parsedArgs.serials.isEmpty()) { | |
builder.useAllAttachedDevices(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment