public TestEventHandler(TextWriter outWriter, string displayLabels, Messages.OnMessage[] subscribers) { _displayLabels = displayLabels; _outWriter = outWriter; _messageSubscribeAdapter = subscribers != null ? new TestMessageSubscriberAdapter(Messages.CombineSubscribers(subscribers)) : null; }
private TestResults RunTests(TestPackage package, TestFilter filter, Messages.OnMessage[] subscribers) { NUnit.Core.TestResult result; ProcessModel processModel = package.Settings.Contains("ProcessModel") ? (ProcessModel)package.Settings["ProcessModel"] : ProcessModel.Default; DomainUsage domainUsage = package.Settings.Contains("DomainUsage") ? (DomainUsage)package.Settings[(object)"DomainUsage"] : DomainUsage.Default; RuntimeFramework runtimeFramework = package.Settings.Contains("RuntimeFramework") ? (RuntimeFramework)package.Settings["RuntimeFramework"] : RuntimeFramework.CurrentFramework; using (new SaveConsoleOutput()) using (TestRunner testRunner = new DefaultTestRunnerFactory().MakeTestRunner(package)) using (var ms = new MemoryStream()) using (var output = CreateOutputWriter(ms)) { try { TestEventHandler eventCollector = new TestEventHandler(_options, output, subscribers); testRunner.Load(package); if (testRunner.Test == null) { testRunner.Unload(); return new TestResults(TestResults.Code.FixtureNotFound, "Unable to locate fixture"); } result = testRunner.Run(eventCollector, filter, false, LoggingThreshold.All); var summary = eventCollector.GetSummary(); output.Flush(); if (summary.UnexpectedError) return new TestResults(TestResults.Code.UnexpectedError, GetResultText(ms), summary); return new TestResults(summary.InvalidAssemblies > 0 ? TestResults.Code.InvalidAssembly : GetCode(summary.FailureCount + summary.ErrorCount + summary.InvalidCount), GetResultText(ms), summary); } catch (FileNotFoundException ex) { output.WriteLine(ex.Message); output.Flush(); return new TestResults(TestResults.Code.InvalidAssembly, GetResultText(ms)); } catch (DirectoryNotFoundException ex) { output.WriteLine(ex.Message); output.Flush(); return new TestResults(TestResults.Code.InvalidAssembly, GetResultText(ms)); } catch (Exception ex) { output.WriteLine(ex.ToString()); output.Flush(); return new TestResults(TestResults.Code.UnexpectedError, GetResultText(ms)); } } }
private TestResults RunTests(TestPackage package, TestFilter filter, Messages.OnMessage[] messageSubscribers) { XmlNode result; using (new SaveConsoleOutput()) using (ITestRunner runner = _engine.GetRunner(package)) using (var ms = new MemoryStream()) using (var output = CreateOutputWriter(ms)) { try { var labels = "ON"; var eventHandler = new TestEventHandler(output, labels, messageSubscribers); result = runner.Run(eventHandler, filter); var reporter = new ResultReporter(result, output, _options); reporter.ReportResults(); output.Flush(); if (reporter.Summary.UnexpectedError) return new TestResults(TestResults.Code.UnexpectedError, GetResultText(ms), reporter.Summary); return new TestResults(reporter.Summary.InvalidAssemblies > 0 ? TestResults.Code.InvalidAssembly : GetCode( reporter.Summary.FailureCount + reporter.Summary.ErrorCount + reporter.Summary.InvalidCount), GetResultText(ms), reporter.Summary); } catch (NUnitEngineException ex) { output.WriteLine(ex.Message); output.Flush(); return new TestResults(TestResults.Code.InvalidArg, GetResultText(ms)); } catch (FileNotFoundException ex) { output.WriteLine(ex.Message); output.Flush(); return new TestResults(TestResults.Code.InvalidAssembly, GetResultText(ms)); } catch (DirectoryNotFoundException ex) { output.WriteLine(ex.Message); output.Flush(); return new TestResults(TestResults.Code.InvalidAssembly, GetResultText(ms)); } catch (Exception ex) { output.WriteLine(ex.ToString()); output.Flush(); return new TestResults(TestResults.Code.UnexpectedError, GetResultText(ms)); } } }
public TestMessageSubscriberAdapter(Messages.OnMessage sink) { this._onMessage = sink; }
public TestMessageSubscriberAdapter(Messages.OnMessage subscriber) { this.subscriber = subscriber; this.assemblyName = "<>"; }
public static TestResults Run(HostedOptions options, Messages.OnMessage[] subscribers) { if (!init) { ServiceManager.Services.ClearServices(); ServiceManager.Services.AddService(new SettingsService()); ServiceManager.Services.AddService(new DomainManager()); ServiceManager.Services.AddService(new ProjectService()); ServiceManager.Services.AddService(new AddinRegistry()); ServiceManager.Services.AddService(new AddinManager()); ServiceManager.Services.AddService(new TestAgency()); ServiceManager.Services.InitializeServices(); init = true; } return new Runner(options).Execute(subscribers); }
public TestResults Execute(Messages.OnMessage[] subscribers) { var package = MakeTestPackage(this._options); TestFilter testFilter; if (!CreateTestFilter(_options, out testFilter)) return new TestResults(TestResults.Code.InvalidArg, ""); return RunTests(package, testFilter, subscribers); }
public static TestResults Run(HostedOptions options, Messages.OnMessage[] messageSubscribers) { using (ITestEngine engine = TestEngineActivator.CreateInstance()) { if (options.WorkDirectory != null) engine.WorkDirectory = options.WorkDirectory; return new Runner(engine, options).Execute(messageSubscribers); } }
public TestResults Execute(Messages.OnMessage[] messageSubscribers) { var package = MakeTestPackage(this._options); TestFilter filter = CreateTestFilter(_options); return RunTests(package, filter, messageSubscribers); }