bool OnTest(XmlNode xml) { var @continue = true; var testCase = FindTestCase(xml.Attributes["type"].Value, xml.Attributes["method"].Value); var timeAttribute = xml.Attributes["time"]; var time = timeAttribute == null ? 0M : Decimal.Parse(timeAttribute.Value, CultureInfo.InvariantCulture); var outputElement = xml.SelectSingleNode("output"); var output = outputElement == null ? String.Empty : outputElement.InnerText; var displayName = xml.Attributes["name"].Value; ITestCaseMessage resultMessage = null; testCaseResults.Total++; testCaseResults.Time += time; switch (xml.Attributes["result"].Value) { case "Pass": resultMessage = new TestPassed(testCase, displayName, time, output); break; case "Fail": { testCaseResults.Failed++; var failure = xml.SelectSingleNode("failure"); var failureInformation = Xunit1ExceptionUtility.ConvertToFailureInformation(failure); resultMessage = new TestFailed(testCase, displayName, time, output, failureInformation.ExceptionTypes, failureInformation.Messages, failureInformation.StackTraces, failureInformation.ExceptionParentIndices); break; } case "Skip": testCaseResults.Skipped++; if (testCase != lastTestCase) { SendTestCaseMessagesWhenAppropriate(testCase); @continue = messageSink.OnMessage(new TestStarting(testCase, displayName)) && @continue; } resultMessage = new TestSkipped(testCase, displayName, xml.SelectSingleNode("reason/message").InnerText); break; } if (resultMessage != null) { @continue = messageSink.OnMessage(resultMessage) && @continue; } @continue = messageSink.OnMessage(new TestFinished(testCase, displayName, time, output)) && @continue; return(@continue && TestClassResults.Continue); }
bool OnTest(XmlNode xml) { var @continue = true; var testCase = FindTestCase(xml.Attributes["type"].Value, xml.Attributes["method"].Value); var timeAttribute = xml.Attributes["time"]; var time = timeAttribute == null ? 0M : Decimal.Parse(timeAttribute.Value, CultureInfo.InvariantCulture); var outputElement = xml.SelectSingleNode("output"); var output = outputElement == null ? String.Empty : outputElement.InnerText; var displayName = xml.Attributes["name"].Value; ITestCaseMessage resultMessage = null; testCaseResults.Total++; testCaseResults.Time += time; switch (xml.Attributes["result"].Value) { case "Pass": resultMessage = new TestPassed(testCase, displayName, time, output); break; case "Fail": { testCaseResults.Failed++; var failure = xml.SelectSingleNode("failure"); var messageElement = failure.SelectSingleNode("message"); var stackTraceElement = failure.SelectSingleNode("stack-trace"); var exceptionTypeAttribute = failure.Attributes["exception-type"]; resultMessage = new TestFailed(testCase, displayName, time, output, exceptionTypeAttribute == null ? String.Empty : exceptionTypeAttribute.Value, messageElement == null ? String.Empty : messageElement.InnerText, stackTraceElement == null ? String.Empty : stackTraceElement.InnerText); break; } case "Skip": testCaseResults.Skipped++; resultMessage = new TestSkipped(testCase, displayName, xml.SelectSingleNode("reason/message").InnerText); break; } if (resultMessage != null) { @continue = messageSink.OnMessage(resultMessage) && @continue; } @continue = messageSink.OnMessage(new TestFinished(testCase, displayName, time, output)) && @continue; return(@continue && TestClassResults.Continue); }
/// <inheritdoc/> public override bool OnMessage(IMessageSinkMessage message) { var testSkipped = message as ITestSkipped; if (testSkipped != null) { SkipCount++; var testFailed = new TestFailed(testSkipped.Test, 0M, "", new[] { "FAIL_SKIP" }, new[] { testSkipped.Reason }, new[] { "" }, new[] { -1 }); return(Visitor.OnMessage(testFailed)); } var testCollectionFinished = message as ITestCollectionFinished; if (testCollectionFinished != null) { testCollectionFinished = new TestCollectionFinished(testCollectionFinished.TestCases, testCollectionFinished.TestCollection, testCollectionFinished.ExecutionTime, testCollectionFinished.TestsRun, testCollectionFinished.TestsFailed + testCollectionFinished.TestsSkipped, 0); return(Visitor.OnMessage(testCollectionFinished)); } var assemblyFinished = message as ITestAssemblyFinished; if (assemblyFinished != null) { assemblyFinished = new TestAssemblyFinished(assemblyFinished.TestCases, assemblyFinished.TestAssembly, assemblyFinished.ExecutionTime, assemblyFinished.TestsRun, assemblyFinished.TestsFailed + assemblyFinished.TestsSkipped, 0); var result = Visitor.OnMessage(assemblyFinished); base.OnMessage(assemblyFinished); return(result); } return(Visitor.OnMessage(message)); }
/// <inheritdoc/> public override bool OnMessageWithTypes(IMessageSinkMessage message, string[] messageTypes) { var hashedTypes = GetMessageTypesAsHashSet(messageTypes); var testSkipped = Cast <ITestSkipped>(message, hashedTypes); if (testSkipped != null) { SkipCount++; var testFailed = new TestFailed(testSkipped.Test, 0M, "", new[] { "FAIL_SKIP" }, new[] { testSkipped.Reason }, new[] { "" }, new[] { -1 }); return(Sink.OnMessageWithTypes(testFailed, TestFailedTypes)); } var testCollectionFinished = Cast <ITestCollectionFinished>(message, hashedTypes); if (testCollectionFinished != null) { testCollectionFinished = new TestCollectionFinished(testCollectionFinished.TestCases, testCollectionFinished.TestCollection, testCollectionFinished.ExecutionTime, testCollectionFinished.TestsRun, testCollectionFinished.TestsFailed + testCollectionFinished.TestsSkipped, 0); return(Sink.OnMessageWithTypes(testCollectionFinished, TestCollectionFinishedTypes)); } var assemblyFinished = Cast <ITestAssemblyFinished>(message, hashedTypes); if (assemblyFinished != null) { assemblyFinished = new TestAssemblyFinished(assemblyFinished.TestCases, assemblyFinished.TestAssembly, assemblyFinished.ExecutionTime, assemblyFinished.TestsRun, assemblyFinished.TestsFailed + assemblyFinished.TestsSkipped, 0); return(Sink.OnMessageWithTypes(assemblyFinished, TestAssemblyFinishedTypes)); } return(Sink.OnMessageWithTypes(message, messageTypes)); }
/// <inheritdoc/> public bool OnMessageWithTypes(IMessageSinkMessage message, HashSet <string> messageTypes) { var testSkipped = message.Cast <ITestSkipped>(messageTypes); if (testSkipped != null) { skipCount++; var testFailed = new TestFailed(testSkipped.Test, 0M, "", new[] { "FAIL_SKIP" }, new[] { testSkipped.Reason }, new[] { "" }, new[] { -1 }); return(innerSink.OnMessage(testFailed)); } var testCollectionFinished = message.Cast <ITestCollectionFinished>(messageTypes); if (testCollectionFinished != null) { testCollectionFinished = new TestCollectionFinished(testCollectionFinished.TestCases, testCollectionFinished.TestCollection, testCollectionFinished.ExecutionTime, testCollectionFinished.TestsRun, testCollectionFinished.TestsFailed + testCollectionFinished.TestsSkipped, 0); return(innerSink.OnMessage(testCollectionFinished)); } var assemblyFinished = message.Cast <ITestAssemblyFinished>(messageTypes); if (assemblyFinished != null) { assemblyFinished = new TestAssemblyFinished(assemblyFinished.TestCases, assemblyFinished.TestAssembly, assemblyFinished.ExecutionTime, assemblyFinished.TestsRun, assemblyFinished.TestsFailed + assemblyFinished.TestsSkipped, 0); return(innerSink.OnMessage(assemblyFinished)); } return(innerSink.OnMessageWithTypes(message, messageTypes)); }
/// <inheritdoc/> public bool OnMessageWithTypes(IMessageSinkMessage message, HashSet<string> messageTypes) { var testSkipped = message.Cast<ITestSkipped>(messageTypes); if (testSkipped != null) { skipCount++; var testFailed = new TestFailed(testSkipped.Test, 0M, "", new[] { "FAIL_SKIP" }, new[] { testSkipped.Reason }, new[] { "" }, new[] { -1 }); return innerSink.OnMessage(testFailed); } var testCollectionFinished = message.Cast<ITestCollectionFinished>(messageTypes); if (testCollectionFinished != null) { testCollectionFinished = new TestCollectionFinished(testCollectionFinished.TestCases, testCollectionFinished.TestCollection, testCollectionFinished.ExecutionTime, testCollectionFinished.TestsRun, testCollectionFinished.TestsFailed + testCollectionFinished.TestsSkipped, 0); return innerSink.OnMessage(testCollectionFinished); } var assemblyFinished = message.Cast<ITestAssemblyFinished>(messageTypes); if (assemblyFinished != null) { assemblyFinished = new TestAssemblyFinished(assemblyFinished.TestCases, assemblyFinished.TestAssembly, assemblyFinished.ExecutionTime, assemblyFinished.TestsRun, assemblyFinished.TestsFailed + assemblyFinished.TestsSkipped, 0); return innerSink.OnMessage(assemblyFinished); } return innerSink.OnMessageWithTypes(message, messageTypes); }
bool OnTest(XmlNode xml) { var @continue = true; var testCase = FindTestCase(xml.Attributes["type"].Value, xml.Attributes["method"].Value); var timeAttribute = xml.Attributes["time"]; var time = timeAttribute == null ? 0M : decimal.Parse(timeAttribute.Value, CultureInfo.InvariantCulture); var outputElement = xml.SelectSingleNode("output"); var output = outputElement == null ? string.Empty : outputElement.InnerText; ITestCaseMessage resultMessage = null; if (currentTest == null) // There is no <start> node for skipped tests, or with xUnit prior to v1.1 { currentTest = new Xunit1Test(testCase, xml.Attributes["name"].Value); } testCaseResults.Total++; testCaseResults.Time += time; switch (xml.Attributes["result"].Value) { case "Pass": resultMessage = new TestPassed(currentTest, time, output); break; case "Fail": { testCaseResults.Failed++; var failure = xml.SelectSingleNode("failure"); var failureInformation = Xunit1ExceptionUtility.ConvertToFailureInformation(failure); resultMessage = new TestFailed(currentTest, time, output, failureInformation.ExceptionTypes, failureInformation.Messages, failureInformation.StackTraces, failureInformation.ExceptionParentIndices); break; } case "Skip": testCaseResults.Skipped++; if (testCase != lastTestCase) { SendTestCaseMessagesWhenAppropriate(testCase); @continue = messageSink.OnMessage(new TestStarting(currentTest)) && @continue; } resultMessage = new TestSkipped(currentTest, xml.SelectSingleNode("reason/message").InnerText); break; } // Since we don't get live output from xUnit.net v1, we just send a single output message just before // the result message (if there was any output). if (!string.IsNullOrEmpty(output)) { @continue = messageSink.OnMessage(new TestOutput(currentTest, output)) && @continue; } if (resultMessage != null) { @continue = messageSink.OnMessage(resultMessage) && @continue; } @continue = messageSink.OnMessage(new TestFinished(currentTest, time, output)) && @continue; currentTest = null; return(@continue && TestClassResults.Continue); }
bool OnTest(XmlNode xml) { var @continue = true; var testCase = FindTestCase(xml.Attributes["type"].Value, xml.Attributes["method"].Value); var timeAttribute = xml.Attributes["time"]; var time = timeAttribute == null ? 0M : Decimal.Parse(timeAttribute.Value, CultureInfo.InvariantCulture); var outputElement = xml.SelectSingleNode("output"); var output = outputElement == null ? String.Empty : outputElement.InnerText; var displayName = xml.Attributes["name"].Value; ITestCaseMessage resultMessage = null; testCaseResults.Total++; testCaseResults.Time += time; switch (xml.Attributes["result"].Value) { case "Pass": resultMessage = new TestPassed(testCase, displayName, time, output); break; case "Fail": { testCaseResults.Failed++; var failure = xml.SelectSingleNode("failure"); var failureInformation = Xunit1ExceptionUtility.ConvertToFailureInformation(failure); resultMessage = new TestFailed(testCase, displayName, time, output, failureInformation.ExceptionTypes, failureInformation.Messages, failureInformation.StackTraces, failureInformation.ExceptionParentIndices); break; } case "Skip": testCaseResults.Skipped++; if (testCase != lastTestCase) { SendTestCaseMessagesWhenAppropriate(testCase); @continue = messageSink.OnMessage(new TestStarting(testCase, displayName)) && @continue; } resultMessage = new TestSkipped(testCase, displayName, xml.SelectSingleNode("reason/message").InnerText); break; } if (resultMessage != null) @continue = messageSink.OnMessage(resultMessage) && @continue; @continue = messageSink.OnMessage(new TestFinished(testCase, displayName, time, output)) && @continue; return @continue && TestClassResults.Continue; }
bool OnTest(XmlNode xml) { var @continue = true; var testCase = FindTestCase(xml.Attributes["type"].Value, xml.Attributes["method"].Value); var timeAttribute = xml.Attributes["time"]; var time = timeAttribute == null ? 0M : decimal.Parse(timeAttribute.Value, CultureInfo.InvariantCulture); var outputElement = xml.SelectSingleNode("output"); var output = outputElement == null ? string.Empty : outputElement.InnerText; ITestCaseMessage resultMessage = null; if (currentTest == null) // There is no <start> node for skipped tests, or with xUnit prior to v1.1 currentTest = new Xunit1Test(testCase, xml.Attributes["name"].Value); testCaseResults.Total++; testCaseResults.Time += time; switch (xml.Attributes["result"].Value) { case "Pass": resultMessage = new TestPassed(currentTest, time, output); break; case "Fail": { testCaseResults.Failed++; var failure = xml.SelectSingleNode("failure"); var failureInformation = Xunit1ExceptionUtility.ConvertToFailureInformation(failure); resultMessage = new TestFailed(currentTest, time, output, failureInformation.ExceptionTypes, failureInformation.Messages, failureInformation.StackTraces, failureInformation.ExceptionParentIndices); break; } case "Skip": testCaseResults.Skipped++; if (testCase != lastTestCase) { SendTestCaseMessagesWhenAppropriate(testCase); @continue = messageSink.OnMessage(new TestStarting(currentTest)) && @continue; } resultMessage = new TestSkipped(currentTest, xml.SelectSingleNode("reason/message").InnerText); break; } // Since we don't get live output from xUnit.net v1, we just send a single output message just before // the result message (if there was any output). if (!string.IsNullOrEmpty(output)) @continue = messageSink.OnMessage(new TestOutput(currentTest, output)) && @continue; if (resultMessage != null) @continue = messageSink.OnMessage(resultMessage) && @continue; @continue = messageSink.OnMessage(new TestFinished(currentTest, time, output)) && @continue; currentTest = null; return @continue && TestClassResults.Continue; }