private void InitializeXmlFile(TestResult result) { ResultSummarizer summaryResults = new ResultSummarizer(result); xmlWriter.Formatting = Formatting.Indented; xmlWriter.WriteStartDocument(false); xmlWriter.WriteComment("This file represents the results of running a test suite"); xmlWriter.WriteStartElement("test-results"); xmlWriter.WriteAttributeString("name", summaryResults.Name); xmlWriter.WriteAttributeString("total", summaryResults.TestsRun.ToString()); xmlWriter.WriteAttributeString("errors", summaryResults.Errors.ToString()); xmlWriter.WriteAttributeString("failures", summaryResults.Failures.ToString()); xmlWriter.WriteAttributeString("not-run", summaryResults.TestsNotRun.ToString()); xmlWriter.WriteAttributeString("inconclusive", summaryResults.Inconclusive.ToString()); xmlWriter.WriteAttributeString("ignored", summaryResults.Ignored.ToString()); xmlWriter.WriteAttributeString("skipped", summaryResults.Skipped.ToString()); xmlWriter.WriteAttributeString("invalid", summaryResults.NotRunnable.ToString()); DateTime now = DateTime.Now; xmlWriter.WriteAttributeString("date", XmlConvert.ToString( now, "yyyy-MM-dd" ) ); xmlWriter.WriteAttributeString("time", XmlConvert.ToString( now, "HH:mm:ss" )); WriteEnvironment(); WriteCultureInfo(); }
public void HandleErrorInFixtureSetup() { MisbehavingFixture fixture = new MisbehavingFixture(); fixture.blowUpInSetUp = true; TestSuiteResult result = (TestSuiteResult)RunTestOnFixture( fixture ); Assert.AreEqual( 1, fixture.setUpCount, "setUpCount" ); Assert.AreEqual( 0, fixture.tearDownCount, "tearDownCOunt" ); // should have one suite and one fixture ResultSummarizer summ = new ResultSummarizer(result); Assert.AreEqual(1, summ.ResultCount); Assert.AreEqual(0, summ.TestsNotRun); Assert.AreEqual(0, summ.SuitesNotRun); Assert.IsTrue(result.Executed, "Suite should have executed"); Assert.IsTrue(result.IsFailure, "Suite should have failed"); Assert.AreEqual("System.Exception : This was thrown from fixture setup", result.Message, "TestSuite Message"); Assert.IsNotNull(result.StackTrace, "TestSuite StackTrace should not be null"); TestResult testResult = ((TestResult)result.Results[0]); Assert.IsTrue(testResult.Executed, "Testcase should have executed"); Assert.AreEqual("TestFixtureSetUp failed in MisbehavingFixture", testResult.Message, "TestSuite Message"); Assert.AreEqual(FailureSite.Parent, testResult.FailureSite); Assert.AreEqual(testResult.StackTrace, testResult.StackTrace, "TestCase stackTrace should match TestSuite stackTrace" ); }
public void RunExplicitTestByCategory() { CategoryFilter filter = new CategoryFilter( "Special" ); TestResult result = mockTestFixture.Run( NullListener.NULL, filter ); ResultSummarizer summarizer = new ResultSummarizer( result ); Assert.AreEqual( 1, summarizer.TestsRun ); }
private void InitializeXmlFile(TestResult result) { ResultSummarizer summaryResults = new ResultSummarizer(result); xmlWriter.Formatting = Formatting.Indented; xmlWriter.WriteStartDocument(false); xmlWriter.WriteComment("This file represents the results of running a test suite"); xmlWriter.WriteStartElement("test-results"); xmlWriter.WriteAttributeString("name", summaryResults.Name); xmlWriter.WriteAttributeString("total", summaryResults.TestsRun.ToString()); xmlWriter.WriteAttributeString("errors", summaryResults.Errors.ToString()); xmlWriter.WriteAttributeString("failures", summaryResults.Failures.ToString()); xmlWriter.WriteAttributeString("not-run", summaryResults.TestsNotRun.ToString()); xmlWriter.WriteAttributeString("inconclusive", summaryResults.Inconclusive.ToString()); xmlWriter.WriteAttributeString("ignored", summaryResults.Ignored.ToString()); xmlWriter.WriteAttributeString("skipped", summaryResults.Skipped.ToString()); xmlWriter.WriteAttributeString("invalid", summaryResults.NotRunnable.ToString()); DateTime now = DateTime.Now; xmlWriter.WriteAttributeString("date", XmlConvert.ToString(now, "yyyy-MM-dd")); xmlWriter.WriteAttributeString("time", XmlConvert.ToString(now, "HH:mm:ss")); WriteEnvironment(); WriteCultureInfo(); }
public void RunExplicitTestDirectly() { Test test = TestFinder.Find( "ExplicitlyRunTest", mockTestFixture, true ); Assert.IsNotNull( test, "Cannot find ExplicitlyRunTest" ); Assert.AreEqual( RunState.Explicit, test.RunState ); TestResult result = test.Run(NullListener.NULL, TestFilter.Empty); ResultSummarizer summarizer = new ResultSummarizer( result ); Assert.AreEqual( 1, summarizer.TestsRun ); }
public void AssemblySetupFixtureWrapsExecutionOfTest() { TestResult result = runTests(null, new Filters.SimpleNameFilter("SomeTestFixture")); ResultSummarizer summ = new ResultSummarizer(result); Assert.AreEqual(1, summ.TestsRun); Assert.IsTrue(result.IsSuccess); TestUtilities.SimpleEventRecorder.Verify("RootNamespaceSetup", "Test", "RootNamespaceTearDown"); }
public void RunIgnoredTestCase() { Type fixtureType = typeof(MockTestFixture); TestCase testCase = TestBuilder.MakeTestCase( fixtureType, "MockTest4" ); Assert.AreEqual(1, testCase.TestCount); TestResult result = testCase.Run(NullListener.NULL); ResultSummarizer summarizer = new ResultSummarizer(result); Assert.AreEqual(0, summarizer.ResultCount); Assert.AreEqual(1, summarizer.TestsNotRun); }
public void RunTestsInFixture() { TestResult result = mockTestFixture.Run(NullListener.NULL, TestFilter.Empty); ResultSummarizer summarizer = new ResultSummarizer( result ); Assert.AreEqual( MockTestFixture.TestsRun, summarizer.TestsRun, "TestsRun" ); Assert.AreEqual( MockTestFixture.NotRunnable, summarizer.NotRunnable, "NotRunnable"); Assert.AreEqual(MockTestFixture.Ignored, summarizer.Ignored, "Ignored"); Assert.AreEqual(MockTestFixture.Errors, summarizer.Errors, "Errors"); Assert.AreEqual(MockTestFixture.Failures, summarizer.Failures, "Failures"); result = TestFinder.Find( "ExplicitlyRunTest", result, true ); Assert.IsNull( result, "ExplicitlyRunTest should not be in results" ); // TODO: Decide if we want to include Explicit tests that are not run in results // Assert.IsNotNull( result, "Cannot find ExplicitlyRunTest result" ); // Assert.IsFalse( result.Executed, "ExplicitlyRunTest should not be executed" ); // Assert.AreEqual( "Explicit selection required", result.Message ); }
protected void LoadAndRunTestAssembly( fit.Parse cell, string testAssembly ) { testRunner = new TestDomain(); if ( !testRunner.Load( new TestPackage(testAssembly) ) ) { this.wrong(cell); cell.addToBody( string.Format( "<font size=-1 color=\"#c08080\"> <i>Failed to load {0}</i></font>", testAssembly ) ); return; } testResult = testRunner.Run(NullListener.NULL); testSummary = new ResultSummarizer( testResult ); this.right( cell ); }
private void Initialize(TestResult result) { ResultSummarizer summaryResults = new ResultSummarizer(result); xmlWriter.Formatting = Formatting.Indented; xmlWriter.WriteStartDocument(false); xmlWriter.WriteComment("This file represents the results of running a test suite"); xmlWriter.WriteStartElement("test-results"); xmlWriter.WriteAttributeString("name", summaryResults.Name); xmlWriter.WriteAttributeString("total", summaryResults.ResultCount.ToString()); xmlWriter.WriteAttributeString("failures", summaryResults.Failures.ToString()); xmlWriter.WriteAttributeString("not-run", summaryResults.TestsNotRun.ToString()); DateTime now = DateTime.Now; xmlWriter.WriteAttributeString("date", now.ToShortDateString()); xmlWriter.WriteAttributeString("time", now.ToShortTimeString()); }
public int Execute() { try { var result = RunTesterBlocking(); var summary = new ResultSummarizer(result); return summary.Errors + summary.Failures + summary.NotRunnable; } catch (FileNotFoundException ex) { Console.WriteLine(ex.Message); return ConsoleUi.FILE_NOT_FOUND; } catch (Exception ex) { //TODO need to expand on error cases better... mimic console runner Console.WriteLine(ex); return ConsoleUi.UNEXPECTED_ERROR; } }
public static int Main(string[] args) { var result = RunTests(args); var total = (from object r in result.Results select r as TestResult).Count(); var results = new ResultSummarizer(result); Console.WriteLine( @"total={0} run={1} passed={2} failures={3} errors={4} not-run={5} inconclusive={6} ignored={7} skipped={8} invalid={9}", total, results.TestsRun, results.Passed, results.Failures, results.Errors, results.TestsNotRun, results.Inconclusive, results.Ignored, results.Skipped, results.NotRunnable); // will return "0" if no tests failed return results.ErrorsAndFailures; }
public void CanIgnoreIndividualTestCases() { Test test = TestBuilder.MakeTestCase( typeof(TestCaseSourceAttributeFixture), "MethodWithIgnoredTestCases"); TestResult result = test.Run(NullListener.NULL, TestFilter.Empty); ResultSummarizer summary = new ResultSummarizer(result); Assert.AreEqual( 3, summary.ResultCount ); Assert.AreEqual( 2, summary.Ignored ); Assert.AreEqual( "Don't Run Me!", ((TestResult)result.Results[2]).Message ); }
public void RunTestsInFixture() { TestResult result = mockTestFixture.Run( NullListener.NULL ); ResultSummarizer summarizer = new ResultSummarizer( result ); Assert.AreEqual( MockTestFixture.Tests - MockTestFixture.NotRun, summarizer.ResultCount ); Assert.AreEqual( MockTestFixture.Ignored, summarizer.TestsNotRun ); result = TestFinder.Find( "ExplicitlyRunTest", result ); Assert.IsNull( result, "ExplicitlyRunTest should not be in results" ); // TODO: Decide if we want to include Explicitly run tests // Assert.IsNotNull( result, "Cannot find ExplicitlyRunTest result" ); // Assert.IsFalse( result.Executed, "ExplicitlyRunTest should not be executed" ); // Assert.AreEqual( "Explicit selection required", result.Message ); }
public void RunNoTestSuite() { Assert.AreEqual(0, noTestSuite.TestCount); TestResult result = noTestSuite.Run(NullListener.NULL); ResultSummarizer summarizer = new ResultSummarizer(result); Assert.AreEqual(0, summarizer.ResultCount); Assert.AreEqual(0, summarizer.TestsNotRun); Assert.AreEqual(1, summarizer.SuitesNotRun); }
public void RerunFixtureAfterTearDownFixed() { MisbehavingFixture fixture = new MisbehavingFixture(); fixture.blowUpInTearDown = true; TestResult result = RunTestOnFixture( fixture ); Assert.AreEqual(1, result.Results.Count); // should have one suite and one fixture ResultSummarizer summ = new ResultSummarizer(result); Assert.AreEqual(1, summ.TestsRun); Assert.AreEqual(0, summ.TestsNotRun); fixture.Reinitialize(); result = RunTestOnFixture( fixture ); Assert.AreEqual( 1, fixture.setUpCount, "setUpCount" ); Assert.AreEqual( 1, fixture.tearDownCount, "tearDownCOunt" ); summ = new ResultSummarizer(result); Assert.AreEqual(1, summ.TestsRun); Assert.AreEqual(0, summ.TestsNotRun); }
public void HandleErrorInFixtureTearDown() { MisbehavingFixture fixture = new MisbehavingFixture(); fixture.blowUpInTearDown = true; TestResult result = RunTestOnFixture( fixture ); Assert.AreEqual(1, result.Results.Count); Assert.IsTrue(result.Executed, "Suite should have executed"); Assert.IsTrue(result.IsFailure, "Suite should have failed" ); Assert.AreEqual( 1, fixture.setUpCount, "setUpCount" ); Assert.AreEqual( 1, fixture.tearDownCount, "tearDownCOunt" ); Assert.AreEqual("This was thrown from fixture teardown", result.Message); Assert.IsNotNull(result.StackTrace, "StackTrace should not be null"); // should have one suite and one fixture ResultSummarizer summ = new ResultSummarizer(result); Assert.AreEqual(1, summ.TestsRun); Assert.AreEqual(0, summ.TestsNotRun); }
public int Execute( ConsoleOptions options ) { XmlTextReader transformReader = GetTransformReader(options); if(transformReader == null) return FILE_NOT_FOUND; TextWriter outWriter = Console.Out; bool redirectOutput = options.output != null && options.output != string.Empty; if ( redirectOutput ) { StreamWriter outStreamWriter = new StreamWriter( options.output ); outStreamWriter.AutoFlush = true; outWriter = outStreamWriter; } TextWriter errorWriter = Console.Error; bool redirectError = options.err != null && options.err != string.Empty; if ( redirectError ) { StreamWriter errorStreamWriter = new StreamWriter( options.err ); errorStreamWriter.AutoFlush = true; errorWriter = errorStreamWriter; } TestRunner testRunner = MakeRunnerFromCommandLine( options ); try { if (testRunner.Test == null) { testRunner.Unload(); Console.Error.WriteLine("Unable to locate fixture {0}", options.fixture); return FIXTURE_NOT_FOUND; } EventCollector collector = new EventCollector( options, outWriter, errorWriter ); TestFilter testFilter = TestFilter.Empty; if ( options.run != null && options.run != string.Empty ) { Console.WriteLine( "Selected test: " + options.run ); testFilter = new SimpleNameFilter( options.run ); } if ( options.include != null && options.include != string.Empty ) { Console.WriteLine( "Included categories: " + options.include ); TestFilter includeFilter = new CategoryExpression( options.include ).Filter; if ( testFilter.IsEmpty ) testFilter = includeFilter; else testFilter = new AndFilter( testFilter, includeFilter ); } if ( options.exclude != null && options.exclude != string.Empty ) { Console.WriteLine( "Excluded categories: " + options.exclude ); TestFilter excludeFilter = new NotFilter( new CategoryExpression( options.exclude ).Filter ); if ( testFilter.IsEmpty ) testFilter = excludeFilter; else if ( testFilter is AndFilter ) ((AndFilter)testFilter).Add( excludeFilter ); else testFilter = new AndFilter( testFilter, excludeFilter ); } TestResult result = null; string savedDirectory = Environment.CurrentDirectory; TextWriter savedOut = Console.Out; TextWriter savedError = Console.Error; try { result = testRunner.Run( collector, testFilter ); } finally { outWriter.Flush(); errorWriter.Flush(); if ( redirectOutput ) outWriter.Close(); if ( redirectError ) errorWriter.Close(); Environment.CurrentDirectory = savedDirectory; Console.SetOut( savedOut ); Console.SetError( savedError ); } Console.WriteLine(); string xmlOutput = CreateXmlOutput( result ); if (options.xmlConsole) { Console.WriteLine(xmlOutput); } else { try { //CreateSummaryDocument(xmlOutput, transformReader ); XmlResultTransform xform = new XmlResultTransform( transformReader ); xform.Transform( new StringReader( xmlOutput ), Console.Out ); } catch( Exception ex ) { Console.WriteLine( "Error: {0}", ex.Message ); return TRANSFORM_ERROR; } } // Write xml output here string xmlResultFile = options.xml == null || options.xml == string.Empty ? "TestResult.xml" : options.xml; using ( StreamWriter writer = new StreamWriter( xmlResultFile ) ) { writer.Write(xmlOutput); } //if ( testRunner != null ) // testRunner.Unload(); if ( collector.HasExceptions ) { collector.WriteExceptions(); return UNEXPECTED_ERROR; } if ( !result.IsFailure ) return OK; ResultSummarizer summ = new ResultSummarizer( result ); return summ.FailureCount; } finally { testRunner.Unload(); } }
public void RunAssembly() { runner.Load( new TestPackage( mockDll ) ); TestResult result = runner.Run( NullListener.NULL ); ResultSummarizer summary = new ResultSummarizer(result); Assert.AreEqual( MockAssembly.Tests - MockAssembly.NotRun, summary.TestsRun ); }
public int Execute( ConsoleOptions options ) { this.workDir = options.work; if (workDir == null || workDir == string.Empty) workDir = Environment.CurrentDirectory; else { workDir = Path.GetFullPath(workDir); if (!Directory.Exists(workDir)) Directory.CreateDirectory(workDir); } TextWriter outWriter = Console.Out; bool redirectOutput = options.output != null && options.output != string.Empty; if ( redirectOutput ) { StreamWriter outStreamWriter = new StreamWriter( Path.Combine(workDir, options.output) ); outStreamWriter.AutoFlush = true; outWriter = outStreamWriter; } TextWriter errorWriter = Console.Error; bool redirectError = options.err != null && options.err != string.Empty; if ( redirectError ) { StreamWriter errorStreamWriter = new StreamWriter( Path.Combine(workDir, options.err) ); errorStreamWriter.AutoFlush = true; errorWriter = errorStreamWriter; } TestPackage package = MakeTestPackage(options); ProcessModel processModel = package.Settings.Contains("ProcessModel") ? (ProcessModel)package.Settings["ProcessModel"] : ProcessModel.Default; DomainUsage domainUsage = package.Settings.Contains("DomainUsage") ? (DomainUsage)package.Settings["DomainUsage"] : DomainUsage.Default; RuntimeFramework framework = package.Settings.Contains("RuntimeFramework") ? (RuntimeFramework)package.Settings["RuntimeFramework"] : RuntimeFramework.CurrentFramework; #if CLR_2_0 || CLR_4_0 Console.WriteLine("ProcessModel: {0} DomainUsage: {1}", processModel, domainUsage); Console.WriteLine("Execution Runtime: {0}", framework); #else Console.WriteLine("DomainUsage: {0}", domainUsage); if (processModel != ProcessModel.Default && processModel != ProcessModel.Single) Console.WriteLine("Warning: Ignoring project setting 'processModel={0}'", processModel); if (!RuntimeFramework.CurrentFramework.Supports(framework)) Console.WriteLine("Warning: Ignoring project setting 'runtimeFramework={0}'", framework); #endif using (TestRunner testRunner = new DefaultTestRunnerFactory().MakeTestRunner(package)) { testRunner.Load(package); if (testRunner.Test == null) { testRunner.Unload(); Console.Error.WriteLine("Unable to locate fixture {0}", options.fixture); return FIXTURE_NOT_FOUND; } EventCollector collector = new EventCollector( options, outWriter, errorWriter ); TestFilter testFilter = TestFilter.Empty; SimpleNameFilter nameFilter = new SimpleNameFilter(); if ( options.run != null && options.run != string.Empty ) { Console.WriteLine( "Selected test(s): " + options.run ); foreach (string name in TestNameParser.Parse(options.run)) nameFilter.Add(name); testFilter = nameFilter; } if (options.runlist != null && options.runlist != string.Empty) { Console.WriteLine("Run list: " + options.runlist); using (StreamReader rdr = new StreamReader(options.runlist)) { // NOTE: We can't use rdr.EndOfStream because it's // not present in .NET 1.x. string line = rdr.ReadLine(); while (line != null) { if (line[0] != '#') nameFilter.Add(line); line = rdr.ReadLine(); } } testFilter = nameFilter; } if ( options.include != null && options.include != string.Empty ) { TestFilter includeFilter = new CategoryExpression( options.include ).Filter; Console.WriteLine("Included categories: " + includeFilter.ToString()); if (testFilter.IsEmpty) testFilter = includeFilter; else testFilter = new AndFilter( testFilter, includeFilter ); } if ( options.exclude != null && options.exclude != string.Empty ) { TestFilter excludeFilter = new NotFilter( new CategoryExpression( options.exclude ).Filter ); Console.WriteLine("Excluded categories: " + excludeFilter.ToString()); if ( testFilter.IsEmpty ) testFilter = excludeFilter; else if ( testFilter is AndFilter ) ((AndFilter)testFilter).Add( excludeFilter ); else testFilter = new AndFilter( testFilter, excludeFilter ); } if (testFilter is NotFilter) ((NotFilter)testFilter).TopLevel = true; TestResult result = null; string savedDirectory = Environment.CurrentDirectory; TextWriter savedOut = Console.Out; TextWriter savedError = Console.Error; try { result = testRunner.Run( collector, testFilter, false, LoggingThreshold.Off ); } finally { outWriter.Flush(); errorWriter.Flush(); if ( redirectOutput ) outWriter.Close(); if ( redirectError ) errorWriter.Close(); Environment.CurrentDirectory = savedDirectory; Console.SetOut( savedOut ); Console.SetError( savedError ); } Console.WriteLine(); int returnCode = UNEXPECTED_ERROR; if (result != null) { string xmlOutput = CreateXmlOutput(result); ResultSummarizer summary = new ResultSummarizer(result); if (options.xmlConsole) { Console.WriteLine(xmlOutput); } else { WriteSummaryReport(summary); if (summary.ErrorsAndFailures > 0 || result.IsError || result.IsFailure) { if (options.stoponerror) { Console.WriteLine("Test run was stopped after first error, as requested."); Console.WriteLine(); } WriteErrorsAndFailuresReport(result); } if (summary.TestsNotRun > 0) WriteNotRunReport(result); if (!options.noresult) { // Write xml output here string xmlResultFile = options.result == null || options.result == string.Empty ? "TestResult.xml" : options.result; using (StreamWriter writer = new StreamWriter(Path.Combine(workDir, xmlResultFile))) { writer.Write(xmlOutput); } } } returnCode = summary.ErrorsAndFailures; } if ( collector.HasExceptions ) { collector.WriteExceptions(); returnCode = UNEXPECTED_ERROR; } return returnCode; } }
private static void WriteSummaryReport( ResultSummarizer summary ) { Console.WriteLine( "Tests run: {0}, Errors: {1}, Failures: {2}, Inconclusive: {3}, Time: {4} seconds", summary.TestsRun, summary.Errors, summary.Failures, summary.Inconclusive, summary.Time); Console.WriteLine( " Not run: {0}, Invalid: {1}, Ignored: {2}, Skipped: {3}", summary.TestsNotRun, summary.NotRunnable, summary.Ignored, summary.Skipped); Console.WriteLine(); }
public void RunMultipleAssemblies() { runner.Load( package2 ); TestResult result = runner.Run( NullListener.NULL ); ResultSummarizer summary = new ResultSummarizer(result); Assert.AreEqual( NoNamespaceTestFixture.Tests + MockAssembly.Tests - MockAssembly.NotRun, summary.TestsRun); }
public void RerunFixtureAfterSetUpFixed() { MisbehavingFixture fixture = new MisbehavingFixture(); fixture.blowUpInSetUp = true; TestResult result = RunTestOnFixture( fixture ); // should have one suite and one fixture ResultSummarizer summ = new ResultSummarizer(result); Assert.AreEqual(1, summ.TestsRun); Assert.AreEqual(0, summ.TestsNotRun); Assert.IsTrue(result.Executed, "Suite should have executed"); //fix the blow up in setup fixture.Reinitialize(); result = RunTestOnFixture( fixture ); Assert.AreEqual( 1, fixture.setUpCount, "setUpCount" ); Assert.AreEqual( 1, fixture.tearDownCount, "tearDownCOunt" ); // should have one suite and one fixture summ = new ResultSummarizer(result); Assert.AreEqual(1, summ.TestsRun); Assert.AreEqual(0, summ.TestsNotRun); }
public void HandleIgnoreInFixtureSetup() { IgnoreInFixtureSetUp fixture = new IgnoreInFixtureSetUp(); TestResult result = RunTestOnFixture( fixture ); // should have one suite and one fixture ResultSummarizer summ = new ResultSummarizer(result); Assert.AreEqual(0, summ.TestsRun); Assert.AreEqual(1, summ.TestsNotRun); Assert.IsFalse(result.Executed, "Suite should not have executed"); Assert.AreEqual("TestFixtureSetUp called Ignore", result.Message); Assert.IsNotNull(result.StackTrace, "StackTrace should not be null"); TestResult testResult = ((TestResult)result.Results[0]); Assert.IsFalse(testResult.Executed, "Testcase should not have executed"); Assert.AreEqual("TestFixtureSetUp called Ignore", testResult.Message ); }
public void ExcludingCategoryDoesNotRunExplicitTestCases() { TestFilter filter = new NotFilter( new CategoryFilter( "MockCategory" ) ); TestResult result = mockTestFixture.Run( NullListener.NULL, filter ); ResultSummarizer summarizer = new ResultSummarizer( result ); Assert.AreEqual( 2, summarizer.ResultCount ); }
public void HandleExceptionInFixtureConstructor() { TestSuite suite = TestBuilder.MakeFixture( typeof( ExceptionInConstructor ) ); TestResult result = suite.Run(NullListener.NULL, TestFilter.Empty); // should have one suite and one fixture ResultSummarizer summ = new ResultSummarizer(result); Assert.AreEqual(1, summ.TestsRun); Assert.AreEqual(0, summ.TestsNotRun); Assert.AreEqual(ResultState.Error, result.ResultState); Assert.AreEqual("SetUp : System.Exception : This was thrown in constructor", result.Message, "TestSuite Message"); Assert.IsNotNull(result.StackTrace, "TestSuite StackTrace should not be null"); TestResult testResult = ((TestResult)result.Results[0]); Assert.IsTrue(testResult.Executed, "Testcase should have executed"); Assert.AreEqual("TestFixtureSetUp failed in ExceptionInConstructor", testResult.Message, "TestSuite Message"); Assert.AreEqual(FailureSite.Parent, testResult.FailureSite); Assert.AreEqual(testResult.StackTrace, testResult.StackTrace, "Test stackTrace should match TestSuite stackTrace" ); }
public void ExcludingCategoryDoesNotRunExplicitTestFixtures() { TestFilter filter = new NotFilter( new CategoryFilter( "MockCategory" ) ); TestAssemblyBuilder builder = new TestAssemblyBuilder(); TestSuite suite = builder.Build( "mock-assembly.dll", true ); TestResult result = suite.Run( NullListener.NULL, filter ); ResultSummarizer summarizer = new ResultSummarizer( result ); Assert.AreEqual( MockAssembly.Tests - MockAssembly.NotRun - 2, summarizer.ResultCount ); }
public void RunAssemblyUsingBeginAndEndRun() { runner.Load( new TestPackage( mockDll ) ); runner.BeginRun( NullListener.NULL ); TestResult result = runner.EndRun(); Assert.IsNotNull( result ); ResultSummarizer summary = new ResultSummarizer( result ); Assert.AreEqual( MockAssembly.Tests - MockAssembly.NotRun, summary.TestsRun ); }
public void RunExplicitTestByName() { Test test = TestFinder.Find( "ExplicitlyRunTest", mockTestFixture ); Assert.IsNotNull( test, "Cannot find ExplicitlyRunTest" ); Assert.AreEqual( RunState.Explicit, test.RunState ); NameFilter filter = new NameFilter( test.TestName ); TestResult result = mockTestFixture.Run( NullListener.NULL, filter ); ResultSummarizer summarizer = new ResultSummarizer( result ); Assert.AreEqual( 1, summarizer.ResultCount ); }
private void OnRunFinished( object sender, TestEventArgs e ) { EnableStopCommand( false ); EnableRunCommand( false ); if ( e.Exception != null ) { if ( ! ( e.Exception is System.Threading.ThreadAbortException ) ) MessageDisplay.Error("NUnit Test Run Failed", e.Exception); } ResultSummarizer summary = new ResultSummarizer( e.Result ); this.runCount.Text = string.Format( "Passed: {0} Failed: {1} Errors: {2} Inconclusive: {3} Invalid: {4} Ignored: {5} Skipped: {6} Time: {7}", summary.Passed, summary.Failures, summary.Errors, summary.Inconclusive, summary.NotRunnable, summary.Ignored, summary.Skipped, summary.Time); try { TestLoader.SaveLastResult("TestResult.xml"); } catch (Exception ex) { log.Warning("Unable to save TestResult.xml\n{0}", ex.ToString()); } EnableRunCommand(true); if (e.Result.ResultState == ResultState.Failure || e.Result.ResultState == ResultState.Error || e.Result.ResultState == ResultState.Cancelled) { this.Activate(); } }
public void RunMultipleAssembliesUsingBeginAndEndRun() { runner.Load( new TestPackage( "TestSuite", assemblies ) ); runner.BeginRun( NullListener.NULL ); TestResult result = runner.EndRun(); Assert.IsNotNull( result ); ResultSummarizer summary = new ResultSummarizer( result ); Assert.AreEqual( NoNamespaceTestFixture.Tests + MockAssembly.Tests - MockAssembly.NotRun, summary.TestsRun); }