Beispiel #1
0
        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);
        }
Beispiel #3
0
        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;
        }