public async Task RunTestsAsync() { if (IsBusy) { return; } IsBusy = true; try { var tests = Tests.Where(t => t.IsSelected).Select(t => t.Test).ToList(); var providers = Factories.Select(f => f.Factory.CreateProvider()).ToList(); TestResults.Clear(); IProgress <ResultTestViewModel> progress = new Progress <ResultTestViewModel>(r => TestResults.Add(r)); await Task.Run(() => { foreach (var result in _engine.RunTests(providers, tests)) { progress.Report(new ResultTestViewModel { Result = result }); } }); } finally { IsBusy = false; } }
async Task RunAllTheTests() { TestResults.Clear(); TableView.ReloadData(); if (RegisteredTests.Instance.Count == 0) { NavigationItem.Title = "No Tests to Run"; } for (int counter = 0; counter < RegisteredTests.Instance.Count; counter++) { var number = counter + 1; NavigationItem.Title = $"Running Test {number} of {RegisteredTests.Instance.Count}"; DeviceTest test = null; try { test = RegisteredTests.Instance.GetTestAtIndex(counter); await test.Execute(); LogTestResult(test, counter, true); } catch (Exception e) { LogFailedException(test, counter, e); } } }
private void ProcessXml() { // Determine the part of the xmloutput string to parse // In some cases Catch2 output contains additional lines of output after the // xml-output. The XmlDocument parser doesn't like this so let's make sure those // extra lines are ignored. var idx = Xml.IndexOf(@"</Catch>"); // Find first occurance of </Catch> if (idx != -1) // Make sure closing tag was found { try { var xml = new XmlDocument(); xml.LoadXml(Xml.Substring(0, idx + 8)); var nodeGroup = xml.SelectSingleNode("Catch/Group"); ExtractTestResults(nodeGroup); return; } catch { // Someting went wrong parsing the XML // Treat as partial result and try to parse as much as possible TestResults.Clear(); // Cleanup any TestResults that may already have been processed } } // Looks like we have a partial result. // Let's try to process as much as possible ProcessXmlPartial(); }
protected void OnClickedStartBenchmark(object sender, EventArgs e) { Stopwatchy = new Stopwatch(); NumberOfIterations = int.Parse(Editor_NumberOfIterations.Text); NumberOfIterationsLeft = NumberOfIterations; TestResults.Clear(); Test(); }
private void RunTests(object parameter) { TimeElapsed = 0; PassedTests = 0; SkippedTests = 0; FailedTests = 0; _isRunning = true; TestResults.Clear(); Task.Factory.StartNew(DoRunTests); }
private void CloseFile(object sender, RoutedEventArgs e) { Doc = null; IfcClassesTree.ItemsSource = null; UpdateDataTable(); ErTree.ItemsSource = null; ConceptRootsTree.ItemsSource = null; // ListResults.ItemsSource = null; TestResults.Clear(); IsFileOpen = false; }
private void ProcessXml() { // Determine the part of the xmloutput string to parse // In some cases Catch2 output contains additional lines of output after the // xml-output. The XmlDocument parser doesn't like this so let's make sure those // extra lines are ignored. var cleanedoutput = XmlOutput.CleanXml(Xml); if (string.IsNullOrEmpty(cleanedoutput)) { // Looks like we have a partial result. // Let's try to process as much as possible ProcessXmlPartial(); return; } try { // Parse the Xml document var xml = new XmlDocument(); xml.LoadXml(cleanedoutput); if (XmlOutput.IsVersion2Xml(cleanedoutput)) { var nodeGroup = xml.SelectSingleNode("Catch/Group"); ExtractTestResults(nodeGroup); return; } else if (XmlOutput.IsVersion3Xml(cleanedoutput)) { var nodeGroup = xml.SelectSingleNode("Catch2TestRun"); ExtractTestResults(nodeGroup); return; } } catch { // Someting went wrong parsing the XML // Treat as partial result and try to parse as much as possible TestResults.Clear(); // Cleanup any TestResults that may already have been processed } // Looks like we have a corrupted/partial result. // Let's try to process as much as possible ProcessXmlPartial(); }
private void HandleTestsPrioritized <TTestCase>(object sender, TestsPrioritizedEventArgs <TTestCase> eventArgs) where TTestCase : ITestCase { for (int i = 0; i < eventArgs.TestCases.Count; i++) { int testCaseId = i; applicationUiExecutor.ExecuteOnUi(() => { var testCase = eventArgs.TestCases[testCaseId]; var currentTestViewModel = TestResults.Single(x => x.FullyQualifiedName == testCase.Id); currentTestViewModel.ExecutionId = testCaseId; }); } applicationUiExecutor.ExecuteOnUi(() => { var allTestsViewModels = TestResults.OrderBy(x => x.ExecutionId).ToList(); TestResults.Clear(); TestResults.AddRange(allTestsViewModels); }); }
// todo: find a way to update the UI fluidly // /* * private static void ProcessUiTasks() * { * var frame = new DispatcherFrame(); * Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background, new DispatcherOperationCallback( * delegate * { * frame.Continue = false; * return null; * }), null); * Dispatcher.PushFrame(frame); * } */ private void WorkerStart() { TestResults.Clear(); _backgroundScheduleRestart = false; if (Model?.ModelFactors == null) { return; } var selectedConcepts = SelectedConcepts(); var selectedExchReq = SelectedExchangeRequirements(); var selectedIfcClasses = SelectedIfcClasses(); if (!selectedConcepts.Any() && !selectedExchReq.Any() && !selectedIfcClasses.Any()) { return; } // define entitites list var entities = _xpWindow.DrawingControl.Selection.ToList(); if (!entities.Any()) { entities = Model?.Instances?.ToList(); } ToggleActivityButton.Content = "Cancel"; ToggleActivityButton.Background = Brushes.Orange; // ProcessUiTasks(); _backgroundTester = new BackgroundWorker { WorkerSupportsCancellation = true, WorkerReportsProgress = true }; _backgroundTester.DoWork += (obj, ea) => GetReport(obj, ea, selectedConcepts, selectedExchReq, selectedIfcClasses, entities, Doc); _backgroundTester.ProgressChanged += bw_ProgressChanged; _backgroundTester.RunWorkerCompleted += bw_RunWorkerCompleted; _backgroundTester.RunWorkerAsync(); }
private async void ExecuteOfflineRunFixModel() { RunStatus = RunStatus.Running; TestResults.Clear(); cancellationTokenSource = new CancellationTokenSource(); try { switch (DiscoveryType) { case DiscoveryType.OfflineDiscovery: await ExecuteGitRun(); break; case DiscoveryType.UserIntendedChangesDiscovery: await ExecuteUserIntendedChangesRun(); break; } RunStatus = RunStatus.Completed; } catch (TerminationConditionReachedException) { RunStatus = RunStatus.Completed; dialogService.ShowInformation($"Execution stopped after {TimeLimit} seconds."); } catch (Exception e) { if (cancellationTokenSource.IsCancellationRequested) { RunStatus = RunStatus.Cancelled; return; } RunStatus = RunStatus.Failed; dialogService.ShowError(e.Message); } }