public void TestCompleted(TestDetails details) { if (_canMoveCursor) { --Console.CursorTop; Console.WriteLine(new string(' ', string.Format(_testingFormat, details.Name).Length)); --Console.CursorTop; } ++_count; if (details.Passed) { PrintWithColour(ConsoleColor.DarkGreen, "Passed\t" + details.Name); ++_passedCount; } else { Console.ForegroundColor = ConsoleColor.DarkRed; Console.WriteLine("Failed\t" + details.Name); Console.WriteLine(details.Thrown); if (!string.IsNullOrWhiteSpace(details.StdOut)) { Console.WriteLine("stdout:"); Console.WriteLine(details.StdOut); } if (!string.IsNullOrWhiteSpace(details.StdErr)) { Console.WriteLine("stderr:"); Console.WriteLine(details.StdErr); } Console.ResetColor(); } }
public void TestCompleted(TestDetails details) { if (!string.IsNullOrEmpty(details.StdOut)) { Console.WriteLine("##teamcity[testStdOut name='{0}' out='{1}']", Escape(details.Name), Escape(details.StdOut)); } if (!string.IsNullOrEmpty(details.StdErr)) { Console.WriteLine("##teamcity[testStdErr name='{0}' out='{1}']", Escape(details.Name), Escape(details.StdErr)); } if (!details.Passed) { Console.WriteLine("##teamcity[testFailed name='{0}' details='{1}']", Escape(details.Name), Escape(details.Thrown.ToString())); } Console.WriteLine("##teamcity[testFinished name='{0}']", Escape(details.Name)); }
public void AssemblyCleanup(string assemblyName) { string failure; TestAssembly testAssembly = _assemblies.First(assembly => assembly.Name == assemblyName); if (testAssembly.IsSane(out failure)) { if (!testAssembly.AssemblyCleanup(out failure)) { var cleanupDetails = new TestDetails { Name = "AssemblyCleanup", Passed = false, Thrown = failure, Time = TimeSpan.Zero }; _output.TestStarted(cleanupDetails.Name); _output.TestCompleted(cleanupDetails); } } }
public void TestCompleted(TestDetails details) { TestCompletedEvent(details); }
public TestDetails RunTest(TestMethod testMethod) { var stdOutBuffer = new StringBuilder(); var stdErrBuffer = new StringBuilder(); var stdOut = Console.Out; var stdError = Console.Error; var details = new TestDetails { Name = _type.FullName + "." + testMethod.Name, Passed = true }; Console.SetOut(new StringWriter(stdOutBuffer)); Console.SetError(new StringWriter(stdErrBuffer)); object instance = null; var timer = Stopwatch.StartNew(); try { instance = _ctor(); details.Passed = _testInitialize.Invoke(instance, out details.Thrown); if (details.Passed) { testMethod.Invoke(instance); } } catch (Exception e) { details.Passed = false; details.Thrown = e.InnerException.ToString(); } details.Passed = details.Passed && _testCleanup.Invoke(instance, out details.Thrown); details.Time = timer.Elapsed; details.StdOut = stdOutBuffer.ToString(); details.StdErr = stdErrBuffer.ToString(); Console.SetOut(stdOut); Console.SetError(stdError); return details; }
public void TestCompleted(TestDetails details) { _outputs.ForEach(output => output.TestCompleted(details)); }