private static TestResults StartEmulatorAndRunTests(IProgressReporter progressReporter, IAndroidDebugBridgeFactory adbFactory, ILogger logger, IEmulator droidEmulator, RunAndroidTestsOptions options) { TimeSpan timeout = TimeSpan.FromSeconds(options.EmulatorStartupWaitTimeInSeconds); using (droidEmulator) { progressReporter.ReportStatus("Waiting for emulator to boot."); droidEmulator.Start(timeout).Wait(); var adb = adbFactory.GetAndroidDebugBridge(); var apkPath = options.ApkPath; progressReporter.ReportStatus("Installing tests APK package."); adb.Install(droidEmulator.Device, apkPath, AdbInstallFlags.ReplaceExistingApplication); progressReporter.ReportTestsStarted(options.ApkPackageName); var testRunner = new AndroidTestRunner(logger, adbFactory, droidEmulator.Device, options.ApkPackageName, options.TestInstrumentationClassPath); var testResults = testRunner.RunTests(); progressReporter.ReportTests(testResults); progressReporter.ReportTestsFinished(options.ApkPackageName); return testResults; } }