コード例 #1
0
        public static TestSuite Create(XElement testSuiteNode)
        {
            var testSuite = new TestSuite();

            testSuite.Name = FocusHelper.ExtractTestMethodName(testSuiteNode);

            var runningTime = testSuiteNode.GetAttributeValueOrDefault("time");

            if (runningTime != null)
            {
                testSuite.RunningTime = TimeSpan.FromSeconds(double.Parse(runningTime, CultureInfo.InvariantCulture));
            }

            // any error messages and/or stack-trace
            var failure = testSuiteNode.Element("failure");

            if (failure != null)
            {
                testSuite.StatusMessage = failure.GetChildElementValueOrDefault("message");
                testSuite.StackTrace    = failure.GetChildElementValueOrDefault("stack-trace");
            }

            // get test suite level categories
            testSuite.Categories.AddRange(NUnitParsingHelper.GetCategories(testSuiteNode, false));
            return(testSuite);
        }
コード例 #2
0
        private static IEnumerable <string> ExtractCategories(XElement testCaseNode)
        {
            var categories = NUnitParsingHelper.GetCategories(testCaseNode, true);

            // if this is a parameterized test, get the categories from the parent test-suite
            var parameterizedTestElement = testCaseNode
                                           .Ancestors("test-suite").ToList()
                                           .Where(x => x.Attribute("type").Value == "ParameterizedTest")
                                           .FirstOrDefault();

            if (null != parameterizedTestElement)
            {
                var paramCategories = NUnitParsingHelper.GetCategories(parameterizedTestElement, false);
                categories.AddRange(paramCategories);
            }
            return(categories);
        }