Skip to content
This repository was archived by the owner on Oct 7, 2025. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.squareup.spoon;

import com.android.annotations.Nullable;
import com.android.annotations.NonNull;
import com.android.ddmlib.AndroidDebugBridge;
import com.android.ddmlib.CollectingOutputReceiver;
import com.android.ddmlib.DdmPreferences;
Expand Down Expand Up @@ -298,47 +298,31 @@ private LogRecordingTestRunListener queryTestSet(final String testPackage,
logDebug(debug, "Querying a list of tests on [%s]", serial);
RemoteAndroidTestRunner runner = createConfiguredRunner(testPackage, testRunner, device);
runner.addBooleanArg("log", true);
// Add the sharding instrumentation arguments if necessary
if (numShards != 0) {
addShardingInstrumentationArgs(runner);
}
if (!isNullOrEmpty(className)) {
if (isNullOrEmpty(methodName)) {
runner.setClassName(className);
} else {
runner.setMethodName(className, methodName);
}
}
if (testSize != null) {
runner.setTestSize(testSize);
}
runner.run(recorder);
return recorder;
}

private void runAllTestOnDevice(final String testPackage, final String testRunner,
final IDevice device, final List<ITestRunListener> listeners) throws Exception {

runTestOnDevice(testPackage, testRunner, device, listeners, null);
logDebug(debug, "Running tests [%s]", serial);
RemoteAndroidTestRunner runner = createConfiguredRunner(testPackage, testRunner, device);
runner.removeInstrumentationArg("package");
if (codeCoverage) {
addCodeCoverageInstrumentationArgs(runner, device);
}
runner.run(listeners);
}

private void runTestOnDevice(final String testPackage, final String testRunner,
final IDevice device, final List<ITestRunListener> listeners,
@Nullable final TestIdentifier test) throws Exception {

if (test != null) {
logDebug(debug, "Running %s [%s]", test, serial);
} else {
logDebug(debug, "Running tests [%s]", serial);
}
@NonNull final TestIdentifier test) throws Exception {
logDebug(debug, "Running %s [%s]", test, serial);
RemoteAndroidTestRunner runner = createConfiguredRunner(testPackage, testRunner, device);
runner.removeInstrumentationArg("package");
if (codeCoverage) {
addCodeCoverageInstrumentationArgs(runner, device);
}
if (test != null) {
runner.setMethodName(test.getClassName(), test.getTestName());
}
runner.setMethodName(test.getClassName(), test.getTestName());
runner.run(listeners);
}

Expand All @@ -356,6 +340,20 @@ private RemoteAndroidTestRunner createConfiguredRunner(String testPackage, Strin
}
runner.addInstrumentationArg(entry.getKey(), entry.getValue());
}
// Add the sharding instrumentation arguments if necessary
if (numShards != 0) {
addShardingInstrumentationArgs(runner);
}
if (!isNullOrEmpty(className)) {
if (isNullOrEmpty(methodName)) {
runner.setClassName(className);
} else {
runner.setMethodName(className, methodName);
}
}
if (testSize != null) {
runner.setTestSize(testSize);
}
return runner;
}

Expand Down