use of com.android.ddmlib.testrunner.TestIdentifier in project buck by facebook.
the class InstrumentationTestRunner method run.
public void run() throws Throwable {
IDevice device = getDevice(this.deviceSerial);
if (device == null) {
System.err.printf("Unable to get device/emulator with serial %s", this.deviceSerial);
System.exit(1);
}
if (this.instrumentationApkPath != null) {
DdmPreferences.setTimeOut(60000);
device.installPackage(this.instrumentationApkPath, true);
if (this.apkUnderTestPath != null) {
device.installPackage(this.apkUnderTestPath, true);
}
}
try {
final RemoteAndroidTestRunner runner = new RemoteAndroidTestRunner(this.packageName, this.testRunner, getDevice(deviceSerial));
for (Map.Entry<String, String> entry : this.extraInstrumentationArguments.entrySet()) {
runner.addInstrumentationArg(entry.getKey(), entry.getValue());
}
BuckXmlTestRunListener listener = new BuckXmlTestRunListener();
ITestRunListener trimLineListener = new ITestRunListener() {
/**
* Before the actual run starts (and after the
* InstrumentationResultsParser is created), we need to do
* some reflection magic to make RemoteAndroidTestRunner not
* trim indentation from lines.
*/
@Override
public void testRunStarted(String runName, int testCount) {
setTrimLine(runner, false);
}
@Override
public void testRunEnded(long elapsedTime, Map<String, String> runMetrics) {
}
@Override
public void testRunFailed(String errorMessage) {
}
@Override
public void testStarted(TestIdentifier test) {
}
@Override
public void testFailed(TestIdentifier test, String trace) {
}
@Override
public void testAssumptionFailure(TestIdentifier test, String trace) {
}
@Override
public void testIgnored(TestIdentifier test) {
}
@Override
public void testEnded(TestIdentifier test, Map<String, String> testMetrics) {
}
@Override
public void testRunStopped(long elapsedTime) {
}
};
listener.setReportDir(this.outputDirectory);
runner.run(trimLineListener, listener);
} finally {
if (this.attemptUninstall) {
// Best effort uninstall from the emulator/device.
device.uninstallPackage(this.packageName);
}
}
}
Aggregations