public void ShouldReportResultsToTheConsole() { using (var console = new RedirectedConsole()) { var listener = new ConsoleListener(); new SelfTestConvention().Execute(listener, typeof(PassFailTestClass)); var testClass = typeof(PassFailTestClass).FullName; console.Lines() .Select(x => Regex.Replace(x, @":line \d+", ":line #")) //Avoid brittle assertion introduced by stack trace line numbers. .ShouldEqual( "Test '" + testClass + ".SkipA' skipped", "Console.Out: FailA", "Console.Error: FailA", "Console.Out: FailB", "Console.Error: FailB", "Console.Out: PassA", "Console.Error: PassA", "Console.Out: PassB", "Console.Error: PassB", "Console.Out: PassC", "Console.Error: PassC", "Test '" + testClass + ".FailA' failed: Fixie.Tests.FailureException", "'FailA' failed!", " at Fixie.Tests.Listeners.ConsoleListenerTests.PassFailTestClass.FailA() in " + PathToThisFile() + ":line #", "Test '" + testClass + ".FailB' failed: Fixie.Tests.FailureException", "'FailB' failed!", " at Fixie.Tests.Listeners.ConsoleListenerTests.PassFailTestClass.FailB() in " + PathToThisFile() + ":line #"); } }
public void ShouldReportPassFailSkipCounts() { using (var console = new RedirectedConsole()) { var listener = new ConsoleListener(); var assembly = typeof(ConsoleListener).Assembly; var version = assembly.GetName().Version; var assemblyResult = new AssemblyResult(assembly.Location); var conventionResult = new ConventionResult("Fake Convention"); var classResult = new ClassResult("Fake Class"); assemblyResult.Add(conventionResult); conventionResult.Add(classResult); classResult.Add(CaseResult.Passed("A", TimeSpan.Zero)); classResult.Add(CaseResult.Failed("B", TimeSpan.Zero, "Message", "Stack Trace", "Exception Type")); classResult.Add(CaseResult.Failed("C", TimeSpan.Zero, "Message", "Stack Trace", "Exception Type")); classResult.Add(CaseResult.Skipped("D", "Reason")); classResult.Add(CaseResult.Skipped("E", "Reason")); classResult.Add(CaseResult.Skipped("F", "Reason")); listener.AssemblyCompleted(assembly, assemblyResult); console.Lines().ShouldEqual("1 passed, 2 failed, 3 skipped, took 0.00 seconds (Fixie " + version + ")."); } }
public void ShouldReportPassFailSkipCounts() { using (var console = new RedirectedConsole()) { var listener = new ConsoleListener(); var assembly = typeof(ConsoleListener).Assembly; var version = assembly.GetName().Version; var assemblyResult = new AssemblyResult(assembly.Location); var conventionResult = new ConventionResult("Fake Convention"); var classResult = new ClassResult("Fake Class"); assemblyResult.Add(conventionResult); conventionResult.Add(classResult); classResult.Add(CaseResult.Passed("A", TimeSpan.Zero)); classResult.Add(CaseResult.Failed("B", TimeSpan.Zero, new ExceptionInfo(new Exception(), new AssertionLibraryFilter()))); classResult.Add(CaseResult.Failed("C", TimeSpan.Zero, new ExceptionInfo(new Exception(), new AssertionLibraryFilter()))); classResult.Add(CaseResult.Skipped("D", "Reason")); classResult.Add(CaseResult.Skipped("E", "Reason")); classResult.Add(CaseResult.Skipped("F", "Reason")); listener.AssemblyCompleted(assembly, assemblyResult); console.Lines().ShouldEqual(string.Format("1 passed, 2 failed, 3 skipped, took {0} seconds (Fixie {1}).", 0.ToString("N2", CultureInfo.CurrentCulture), version)); } }
public void ShouldNotAffectOutputByDefault() { using (var console = new RedirectedConsole()) { var listener = new ConsoleListener(); var convention = new SelfTestConvention(); var conventionRunner = new ConventionRunner(); conventionRunner.Run(convention, listener, typeof(SampleTestClass)); console .Output.Split(new[] { Environment.NewLine }, StringSplitOptions.None) .Select(x => Regex.Replace(x, @":line \d+", ":line #")) //Avoid brittle assertion introduced by stack trace line numbers. .ShouldEqual( "Test 'Fixie.Tests.AssertionLibraryFilteringTests+SampleTestClass.DivideByZero' failed: System.DivideByZeroException", "Attempted to divide by zero.", " at Fixie.Tests.AssertionLibraryFilteringTests.SampleTestClass.DivideByZero() in " + PathToThisFile() + ":line #", "", "Test 'Fixie.Tests.AssertionLibraryFilteringTests+SampleTestClass.FailedAssertion' failed: Fixie.Tests.SampleAssertionLibrary.AssertionException", "Expected 1, but was 0.", " at Fixie.Tests.SampleAssertionLibrary.SampleAssert.AreEqual(Int32 expected, Int32 actual) in " + PathToThisFile() + ":line #", " at Fixie.Tests.AssertionLibraryFilteringTests.SampleTestClass.FailedAssertion() in " + PathToThisFile() + ":line #", "", ""); } }
public void ShouldReportPassFailSkipCounts() { using (var console = new RedirectedConsole()) { var listener = new ConsoleListener(); var assembly = typeof(ConsoleListener).Assembly; var version = assembly.GetName().Version; listener.AssemblyCompleted(assembly, new AssemblyResult(1, 2, 3)); console.Lines().ShouldEqual("1 passed, 2 failed, 3 skipped (Fixie " + version + ")."); } }