コード例 #1
0
        /// <summary>
        /// Logs the test node by calling <see cref="IRunnerLogger.TestFinished"/>. It will also call
        /// <see cref="IRunnerLogger.TestPassed"/>, <see cref="IRunnerLogger.TestFailed"/>, or
        /// <see cref="IRunnerLogger.TestSkipped"/> as appropriate.
        /// </summary>
        /// <param name="testNode">The test node.</param>
        /// <param name="logger">The logger.</param>
        /// <returns>Returns true if the user wishes to continue running tests; returns false otherwise.</returns>
        public static bool LogTestNode(XmlNode testNode, IRunnerLogger logger)
        {
            string name       = testNode.Attributes["name"].Value;
            string type       = testNode.Attributes["type"].Value;
            string method     = testNode.Attributes["method"].Value;
            double time       = 0;
            string output     = null;
            string stackTrace = null;

            if (testNode.Attributes["time"] != null)
            {
                time = Double.Parse(testNode.Attributes["time"].Value, CultureInfo.InvariantCulture);
            }
            if (testNode.SelectSingleNode("output") != null)
            {
                output = testNode.SelectSingleNode("output").InnerText;
            }
            if (testNode.SelectSingleNode("failure/stack-trace") != null)
            {
                stackTrace = testNode.SelectSingleNode("failure/stack-trace").InnerText;
            }

            switch (testNode.Attributes["result"].Value)
            {
            case "Pass":
                logger.TestPassed(name, type, method, time, output);
                break;

            case "Fail":
                logger.TestFailed(name, type, method, time, output,
                                  testNode.SelectSingleNode("failure").Attributes["exception-type"].Value,
                                  testNode.SelectSingleNode("failure/message").InnerText,
                                  stackTrace);
                break;

            case "Skip":
                logger.TestSkipped(name, type, method,
                                   testNode.SelectSingleNode("reason/message").InnerText);
                break;
            }

            return(logger.TestFinished(name, type, method));
        }
コード例 #2
0
ファイル: XmlLoggerAdapter.cs プロジェクト: paulecoyote/xunit
        /// <summary>
        /// Logs the test node by calling <see cref="IRunnerLogger.TestFinished"/>. It will also call
        /// <see cref="IRunnerLogger.TestPassed"/>, <see cref="IRunnerLogger.TestFailed"/>, or
        /// <see cref="IRunnerLogger.TestSkipped"/> as appropriate.
        /// </summary>
        /// <param name="testNode">The test node.</param>
        /// <param name="logger">The logger.</param>
        /// <returns>Returns true if the user wishes to continue running tests; returns false otherwise.</returns>
        public static bool LogTestNode(XmlNode testNode, IRunnerLogger logger)
        {
            string name = testNode.Attributes["name"].Value;
            string type = testNode.Attributes["type"].Value;
            string method = testNode.Attributes["method"].Value;
            double time = 0;
            string output = null;
            string stackTrace = null;

            if (testNode.Attributes["time"] != null)
                time = Double.Parse(testNode.Attributes["time"].Value, CultureInfo.InvariantCulture);
            if (testNode.SelectSingleNode("output") != null)
                output = testNode.SelectSingleNode("output").InnerText;
            if (testNode.SelectSingleNode("failure/stack-trace") != null)
                stackTrace = testNode.SelectSingleNode("failure/stack-trace").InnerText;

            switch (testNode.Attributes["result"].Value)
            {
                case "Pass":
                    logger.TestPassed(name, type, method, time, output);
                    break;

                case "Fail":
                    logger.TestFailed(name, type, method, time, output,
                                      testNode.SelectSingleNode("failure").Attributes["exception-type"].Value,
                                      testNode.SelectSingleNode("failure/message").InnerText,
                                      stackTrace);
                    break;

                case "Skip":
                    logger.TestSkipped(name, type, method,
                                       testNode.SelectSingleNode("reason/message").InnerText);
                    break;
            }

            return logger.TestFinished(name, type, method);
        }