public bool Step() { int remaining = test_step_count; while (actions.Count > 0 && remaining > 0) { var a = actions.Dequeue(); a(); --remaining; } if (actions.Count == 0) { var res = new ResultReporter(rootAction.testResult, Console.Out); if ((res.Summary.FailureCount + res.Summary.ErrorCount) > 0) { test_status = "FAIL"; } else { test_status = "PASS"; } res.ReportResults(); return(false); } return(true); }
private void ExecuteTests() { ITestResult result = runner.Run(TestListener.NULL, TestFilter.Empty); ResultReporter reporter = new ResultReporter(result, writer); reporter.ReportResults(); ResultSummary summary = reporter.Summary; this.Total.Text = summary.TestCount.ToString(); this.Failures.Text = summary.FailureCount.ToString(); this.Errors.Text = summary.ErrorCount.ToString(); this.NotRun.Text = summary.NotRunCount.ToString(); this.Passed.Text = summary.PassCount.ToString(); this.Inconclusive.Text = summary.InconclusiveCount.ToString(); this.Notice.Visibility = Visibility.Collapsed; }
public override void Initialize() { var path = Path.Combine(Player.Core.GetPath(AimpCorePathType.Plugins), "AimpTestRunner"); _logWriter = new StreamWriter(Path.Combine(path, "integration.tests.log")); try { AppDomain.CurrentDomain.SetData("APPBASE", path); Environment.CurrentDirectory = path; _testResultFile = Path.Combine(path, "integration.tests.xml"); if (Player.Win32Manager.GetAimpHandle() == IntPtr.Zero) { _logWriter.WriteLine("Unable to run test. This is not AIMP."); _logWriter.Flush(); _logWriter.Close(); Terminate(); } _engine = TestEngineActivator.CreateInstance(); _engine.WorkDirectory = path; _engine.Initialize(); TestPackage package = new TestPackage(Path.Combine(path, "AimpTestRunner_plugin.dll")); package.Settings.Add("ProcessModel", "Single"); ITestRunner runner = _engine.GetRunner(package); AimpTestContext.Instance.AimpPlayer = Player; Player.ServiceMessageDispatcher.Hook(new Hook((type, i, arg3) => { if (type == AimpCoreMessageType.EventLoaded && !_inProgress) { _inProgress = true; try { XmlNode testResult = runner.Run(this, TestFilter.Empty); _resultWriter.CheckWritability(_testResultFile); _resultWriter.WriteResultFile(testResult, _testResultFile); var reporter = new ResultReporter(testResult, new ExtendedTextWrapper(_logWriter)); reporter.ReportResults(); } catch (Exception e) { _logWriter.WriteLine(e.ToString()); } finally { _logWriter.Flush(); Terminate(); } } return(new AimpActionResult(ActionResultType.OK)); })); } catch (Exception e) { _logWriter.WriteLine(e.ToString()); _logWriter.Flush(); _logWriter.Close(); Terminate(); } }
private ConsoleTestRunnerResult RunTests(TestPackage package) { var labels = (_options.DisplayTestLabels ?? LabelsOutputMode.On).ToString().ToUpperInvariant(); XmlNode?result = null; NUnitEngineUnloadException?unloadException = null; NUnitEngineException? engineException = null; try { using (new SaveConsoleOutput()) using (var runner = _engine.GetRunner(package)) { var eventHandler = new TestEventHandler(_outWriter, labels); var testFilter = new TestFilterBuilder().GetFilter(); result = runner.Run(eventHandler, testFilter); } } catch (NUnitEngineUnloadException ex) { unloadException = ex; } catch (NUnitEngineException ex) { engineException = ex; } if (result != null) { var reporter = new ResultReporter(result, _outWriter, _options); reporter.ReportResults(); if (engineException != null) { _outWriter.WriteLine(ColorStyle.Error, Environment.NewLine + ExceptionHelper.BuildMessage(engineException)); return(new ConsoleTestRunnerResult(new UnexpectedError(engineException))); } if (unloadException != null) { _outWriter.WriteLine(ColorStyle.Warning, Environment.NewLine + ExceptionHelper.BuildMessage(unloadException)); } if (reporter.Summary.UnexpectedError) { return(new ConsoleTestRunnerResult(default(UnexpectedError))); } if (reporter.Summary.InvalidAssemblies > 0) { return(new ConsoleTestRunnerResult(default(InvalidAssembly))); } if (reporter.Summary.InvalidTestFixtures > 0) { return(new ConsoleTestRunnerResult(default(InvalidTestFixture))); } var failureCount = reporter.Summary.FailureCount + reporter.Summary.ErrorCount + reporter.Summary.InvalidCount; if (failureCount == 0) { return(new ConsoleTestRunnerResult(new SomeFailures(reporter.Summary))); } return(new ConsoleTestRunnerResult(new AllSuccess(reporter.Summary))); } // If we got here, it's because we had an exception, but check anyway if (engineException != null) { _outWriter.WriteLine(ColorStyle.Error, ExceptionHelper.BuildMessage(engineException)); _outWriter.WriteLine(); _outWriter.WriteLine(ColorStyle.Error, ExceptionHelper.BuildMessageAndStackTrace(engineException)); } return(new ConsoleTestRunnerResult(new UnexpectedError(engineException))); }