public override void OnStart() { base.OnStart(); // is needed for synchronized running tests. SynchronizationContext.SetSynchronizationContext(new SynchronizationContext()); AddTests(); var resultsBundle = new Bundle(); int failedCount = -1; try { _progress.Send("Getting a list of tests..."); var testAssemblyViewModels = _instrumentDeviceRunner.Discover().GetAwaiter().GetResult(); var testCases = testAssemblyViewModels.SelectMany(x => x.TestCases).ToList(); _progress.Send(TestCasesToString(testCases), $"{testCases.Count()} test cases were found."); for (var i = 1; i <= testCases.Count; i++) { var testCase = testCases[i - 1]; _instrumentDeviceRunner.Run(testCase).GetAwaiter().GetResult(); _progress.Send($"{i}/{testCases.Count} [{testCase.Result.ToString().ToUpper()}] {testCase.TestCase.DisplayName}"); } _progress.Send("Saving test results..."); _cachedResultChannel.SaveTo(_originalResultChannel, "RunEverything").GetAwaiter().GetResult(); _cachedResultChannel.Clear(); failedCount = testCases.Count(x => x.Result == TestState.Failed); resultsBundle.WithValue("Results", ResultsToString(testCases)); } catch (Exception ex) { resultsBundle.WithValue("error", ex.ToString()); } Finish((failedCount == 0) ? Result.Ok : Result.Canceled, resultsBundle); }