Java Code Examples for com.android.ddmlib.testrunner.RemoteAndroidTestRunner#setClassName()
The following examples show how to use
com.android.ddmlib.testrunner.RemoteAndroidTestRunner#setClassName() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestLaunchAction.java From NBANDROID-V2 with Apache License 2.0 | 5 votes |
@Override public boolean doLaunch(LaunchInfo launchInfo, final IDevice device, final Project project, MainActivityConfiguration mainActivityConfiguration) { Preconditions.checkNotNull(project); String runnerClass = launchInfo.launchConfig.getInstrumentationRunner(); final RemoteAndroidTestRunner runner = new RemoteAndroidTestRunner( launchInfo.manifestData.getPackage(), runnerClass != null ? runnerClass : AndroidProjectProperties.INSTR_RUNNER_DEFAULT, device); if (!Strings.isNullOrEmpty(launchInfo.testClass)) { // if (mLaunchInfo.getTestMethod() != null) { // runner.setMethodName(mLaunchInfo.getTestClass(), mLaunchInfo.getTestMethod()); // } else { runner.setClassName(launchInfo.testClass); // } } // // if (mLaunchInfo.getTestPackage() != null) { // runner.setTestPackageName(mLaunchInfo.getTestPackage()); // } runner.setDebug(launchInfo.debug); if (launchInfo.debug) { // TODO this is wrong // we need to start test runner asynchronously to be able to attach RequestProcessor.getDefault().post(new Runnable() { @Override public void run() { callRunner(runner, device, project); } }); return true; } return callRunner(runner, device, project); }
Example 2
Source File: StockAndroidTestLaunchTask.java From intellij with Apache License 2.0 | 4 votes |
@Override @SuppressWarnings("FutureReturnValueIgnored") public LaunchResult run( Executor executor, 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 LaunchResult.error("", getDescription()); } 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(printer)); } catch (Exception e) { LOG.info(e); printer.stderr("Error: Unexpected exception while running tests: " + e); } }); return LaunchResult.success(); }