AI 143918: am: CL 143917 ADT Android JUnit: Change logic to provide an explicit project or package to run to the device InstrumentationTestRunner, instead of providing the potentially huge list of test classes. Discontinue support for running all tests in a source folder.
Original author: brettchabot Merged from: //branches/cupcake/... Automated import of CL 143918
This commit is contained in:
committed by
The Android Open Source Project
parent
37747492ad
commit
47eccd8c05
@@ -49,6 +49,7 @@ public class RemoteAndroidTestRunner {
|
||||
private static final String LOG_ARG_NAME = "log";
|
||||
private static final String DEBUG_ARG_NAME = "debug";
|
||||
private static final String COVERAGE_ARG_NAME = "coverage";
|
||||
private static final String PACKAGE_ARG_NAME = "package";
|
||||
|
||||
/**
|
||||
* Creates a remote Android test runner.
|
||||
@@ -145,6 +146,16 @@ public class RemoteAndroidTestRunner {
|
||||
setClassName(className + METHOD_SEPARATOR + testName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets to run all tests in specified package
|
||||
* Must be called before 'run'.
|
||||
*
|
||||
* @param packageName fully qualified package name (eg x.y.z)
|
||||
*/
|
||||
public void setTestPackageName(String packageName) {
|
||||
addInstrumentationArg(PACKAGE_ARG_NAME, packageName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a argument to include in instrumentation command.
|
||||
* <p/>
|
||||
|
||||
@@ -17,16 +17,17 @@
|
||||
package com.android.ddmlib.testrunner;
|
||||
|
||||
import com.android.ddmlib.Client;
|
||||
import com.android.ddmlib.Device.DeviceState;
|
||||
import com.android.ddmlib.FileListingService;
|
||||
import com.android.ddmlib.IDevice;
|
||||
import com.android.ddmlib.IShellOutputReceiver;
|
||||
import com.android.ddmlib.log.LogReceiver;
|
||||
import com.android.ddmlib.RawImage;
|
||||
import com.android.ddmlib.SyncService;
|
||||
import com.android.ddmlib.Device.DeviceState;
|
||||
import com.android.ddmlib.log.LogReceiver;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
@@ -80,6 +81,17 @@ public class RemoteAndroidTestRunnerTest extends TestCase {
|
||||
testName, TEST_PACKAGE, TEST_RUNNER), mMockDevice.getLastShellCommand());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the building of the instrumentation runner command with test package set.
|
||||
*/
|
||||
public void testRunWithPackage() {
|
||||
final String packageName = "foo.test";
|
||||
mRunner.setTestPackageName(packageName);
|
||||
mRunner.run(new EmptyListener());
|
||||
assertStringsEquals(String.format("am instrument -w -r -e package %s %s/%s", packageName,
|
||||
TEST_PACKAGE, TEST_RUNNER), mMockDevice.getLastShellCommand());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the building of the instrumentation runner command with extra argument added.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user