use of com.android.tools.idea.testartifacts.instrumented.AndroidTestListener in project intellij by bazelbuild.
the class StockAndroidTestLaunchTask method perform.
@Override
@SuppressWarnings("FutureReturnValueIgnored")
public boolean perform(IDevice device, final LaunchStatus launchStatus, final ConsolePrinter printer) {
printer.stdout("Running tests\n");
final RemoteAndroidTestRunner runner = new RemoteAndroidTestRunner(testApplicationId, instrumentationTestRunner, device);
switch(configState.getTestingType()) {
case BlazeAndroidTestRunConfigurationState.TEST_ALL_IN_MODULE:
break;
case BlazeAndroidTestRunConfigurationState.TEST_ALL_IN_PACKAGE:
runner.setTestPackageName(configState.getPackageName());
break;
case BlazeAndroidTestRunConfigurationState.TEST_CLASS:
runner.setClassName(configState.getClassName());
break;
case BlazeAndroidTestRunConfigurationState.TEST_METHOD:
runner.setMethodName(configState.getClassName(), configState.getMethodName());
break;
default:
LOG.error(String.format("Unrecognized testing type: %d", configState.getTestingType()));
return false;
}
runner.setDebug(waitForDebugger);
runner.setRunOptions(configState.getExtraOptions());
printer.stdout("$ adb shell " + runner.getAmInstrumentCommand());
// run in a separate thread as this will block until the tests complete
ApplicationManager.getApplication().executeOnPooledThread(() -> {
try {
runner.run(new AndroidTestListener(launchStatus, printer));
} catch (Exception e) {
LOG.info(e);
printer.stderr("Error: Unexpected exception while running tests: " + e);
}
});
return true;
}
Aggregations