Ejemplo n.º 1
0
            public static TestSpecifier Parse(XElement element)
            {
                TestSpecifier spec = new TestSpecifier();

                switch (element.Name.LocalName.ToLowerInvariant())
                {
                case "method":
                    spec.Type = TestSpecifierType.Method;
                    break;

                case "class":
                    spec.Type = TestSpecifierType.Class;
                    break;

                case "namespace":
                    spec.Type = TestSpecifierType.Namespace;
                    break;

                default:
                    throw new XmlException("Unrecognized node: " + element.Name);
                }

                spec.Specifier = element.Attribute("Name").Value;

                return(spec);
            }
Ejemplo n.º 2
0
            public static TestList Parse(XElement element)
            {
                TestList group = new TestList();

                group.Name = element.Attribute("Name")?.Value;

                foreach (var item in element.Elements())
                {
                    group.TestSpecifiers.Add(TestSpecifier.Parse(item));
                }

                return(group);
            }
Ejemplo n.º 3
0
        public List <string> GetXunitArgsFromTestConfig()
        {
            List <TestSpecifier> testsToSkip = new List <TestSpecifier>();
            List <TestList>      testLists   = new List <TestList>();

            List <string> ret = new List <string>();

            foreach (var testConfigFile in TestConfigFiles)
            {
                var testConfig = XDocument.Load(testConfigFile);
                foreach (var item in testConfig.Root.Elements())
                {
                    if (item.Name.LocalName.Equals("TestList", StringComparison.OrdinalIgnoreCase))
                    {
                        testLists.Add(TestList.Parse(item));
                    }
                    else if (item.Name.LocalName.Equals("SkippedTests", StringComparison.OrdinalIgnoreCase))
                    {
                        var skippedGroup = TestList.Parse(item);
                        testsToSkip.AddRange(skippedGroup.TestSpecifiers);
                    }
                    else
                    {
                        if (bool.TryParse(item.Attribute("Skip")?.Value ?? string.Empty, out bool shouldSkip) &&
                            shouldSkip)
                        {
                            testsToSkip.Add(TestSpecifier.Parse(item));
                        }
                    }
                }
            }

            foreach (var testList in testLists.Where(g => TestListsToRun.Contains(g.Name)))
            {
                foreach (var testSpec in testList.TestSpecifiers)
                {
                    if (testSpec.Type == TestSpecifier.TestSpecifierType.Method)
                    {
                        ret.Add("-method");
                    }
                    else if (testSpec.Type == TestSpecifier.TestSpecifierType.Class)
                    {
                        ret.Add("-class");
                    }
                    else if (testSpec.Type == TestSpecifier.TestSpecifierType.Namespace)
                    {
                        ret.Add("-namespace");
                    }
                    else
                    {
                        throw new ArgumentException("Unrecognized test specifier type: " + testSpec.Type);
                    }
                    ret.Add(testSpec.Specifier);
                }
            }

            foreach (var testSpec in testsToSkip)
            {
                if (testSpec.Type == TestSpecifier.TestSpecifierType.Method)
                {
                    ret.Add("-nomethod");
                }
                else if (testSpec.Type == TestSpecifier.TestSpecifierType.Class)
                {
                    ret.Add("-noclass");
                }
                else if (testSpec.Type == TestSpecifier.TestSpecifierType.Namespace)
                {
                    ret.Add("-nonamespace");
                }
                else
                {
                    throw new ArgumentException("Unrecognized test specifier type: " + testSpec.Type);
                }
                ret.Add(testSpec.Specifier);
            }

            return(ret);
        }