Inheritance: NUnit.Framework.Internal.Filters.CompositeFilter
コード例 #1
0
    static void RunAllTestsIOS()
    {
        try {
            AltUnityTesterEditor.InitEditorConfiguration();
            UnityEngine.Debug.Log("Started running test");
            System.Reflection.Assembly[] assemblies = System.AppDomain.CurrentDomain.GetAssemblies();
            System.Reflection.Assembly   assembly   = assemblies.FirstOrDefault(assemblyName => assemblyName.GetName().Name.Equals("Assembly-CSharp-Editor"));

            var testSuite2 = (NUnit.Framework.Internal.TestSuite) new NUnit.Framework.Api.DefaultTestAssemblyBuilder().Build(assembly, new System.Collections.Generic.Dictionary <string, object>());

            NUnit.Framework.Internal.Filters.OrFilter filter = new NUnit.Framework.Internal.Filters.OrFilter();
            foreach (var test in testSuite2.Tests)
            {
                foreach (var t in test.Tests)
                {
                    UnityEngine.Debug.Log(t.FullName);
                    filter.Add(new NUnit.Framework.Internal.Filters.FullNameFilter(t.FullName));
                }
            }

            NUnit.Framework.Interfaces.ITestListener listener = new TestRunListener(null);
            var testAssemblyRunner = new NUnit.Framework.Api.NUnitTestAssemblyRunner(new NUnit.Framework.Api.DefaultTestAssemblyBuilder());
            testAssemblyRunner.Load(assembly, new System.Collections.Generic.Dictionary <string, object>());
            var result = testAssemblyRunner.Run(listener, filter);
            if (result.FailCount > 0)
            {
                UnityEditor.EditorApplication.Exit(1);
            }
        } catch (System.Exception e) {
            UnityEngine.UnityEngine.Debug.LogError(e);
            UnityEditor.EditorApplication.Exit(1);
        }
    }
コード例 #2
0
ファイル: DeMorganOnFiltersTest.cs プロジェクト: wbratz/nunit
        static DeMorganOnFiltersTest()
        {
            var filterParts = new TestFilter[]
            {
                new CategoryFilter("Dummy"),
                new MethodNameFilter("Test1"),
                new PropertyFilter("Priority", "High"),
                new PropertyFilter("Priority", "Low")
            };

            filterPairs = new List <TestFilter[]>();
            foreach (var part1 in filterParts)
            {
                foreach (var part2 in filterParts)
                {
                    var and = new AndFilter(part1, new NotFilter(part2));
                    var or  = new OrFilter(new NotFilter(part1), part2);
                    filterPairs.Add(new TestFilter[2] {
                        new NotFilter(and), or
                    });
                    filterPairs.Add(new TestFilter[2] {
                        and, new NotFilter(or)
                    });
                }
            }
        }
コード例 #3
0
ファイル: OrFilterTests.cs プロジェクト: stevenaw/nunit
        public void MatchTestEmpty()
        {
            var filter = new OrFilter(new TestFilter[] {});

            Assert.False(filter.Match(_dummyFixture));
            Assert.False(filter.Match(_anotherFixture));
            Assert.False(filter.Match(_yetAnotherFixture));
        }
コード例 #4
0
ファイル: OrFilterTests.cs プロジェクト: stevenaw/nunit
        public void MatchTestMixed()
        {
            var filter = new OrFilter(new CategoryFilter("Dummy"), new FullNameFilter(ANOTHER_CLASS));

            Assert.That(filter.Match(_dummyFixture));
            Assert.That(filter.Match(_anotherFixture));

            Assert.False(filter.Match(_yetAnotherFixture));
        }
コード例 #5
0
ファイル: OrFilterTests.cs プロジェクト: zzekikaya/nunit
        public void MatchTest()
        {
            var filter = new OrFilter(new CategoryFilter("Dummy"), new CategoryFilter("Another"));

            Assert.That(filter.Match(_dummyFixture));
            Assert.That(filter.Match(_anotherFixture));

            Assert.False(filter.Match(_yetAnotherFixture));
        }
コード例 #6
0
ファイル: OrFilterTests.cs プロジェクト: nunit/nunit
        public void MatchTest()
        {
            var filter = new OrFilter(new CategoryFilter("Dummy"), new CategoryFilter("Another"));

            Assert.That(filter.Match(_dummyFixture));
            Assert.That(filter.Match(_anotherFixture));

            Assert.False(filter.Match(_yetAnotherFixture));
        }
コード例 #7
0
ファイル: OrFilterTests.cs プロジェクト: stevenaw/nunit
        public void MatchTestFullNameRegex()
        {
            var filter = new OrFilter(new FullNameFilter(DUMMY_CLASS_REGEX, isRegex: true), new FullNameFilter(ANOTHER_CLASS_REGEX, isRegex: true));

            Assert.That(filter.Match(_dummyFixture));
            Assert.That(filter.Match(_anotherFixture));

            Assert.False(filter.Match(_yetAnotherFixture));
        }
コード例 #8
0
ファイル: OrFilterTests.cs プロジェクト: nunit/nunit
        public void ExplicitMatchTest()
        {
            var filter = new OrFilter(new CategoryFilter("Dummy"), new CategoryFilter("Another"));

            Assert.That(filter.IsExplicitMatch(_topLevelSuite));
            Assert.That(filter.IsExplicitMatch(_dummyFixture));
            Assert.False(filter.IsExplicitMatch(_dummyFixture.Tests[0]));
            Assert.That(filter.IsExplicitMatch(_anotherFixture));
            Assert.False(filter.IsExplicitMatch(_anotherFixture.Tests[0]));

            Assert.False(filter.IsExplicitMatch(_yetAnotherFixture));
        }
コード例 #9
0
ファイル: OrFilterTests.cs プロジェクト: zzekikaya/nunit
        public void ExplicitMatchTest()
        {
            var filter = new OrFilter(new CategoryFilter("Dummy"), new CategoryFilter("Another"));

            Assert.That(filter.IsExplicitMatch(_topLevelSuite));
            Assert.That(filter.IsExplicitMatch(_dummyFixture));
            Assert.False(filter.IsExplicitMatch(_dummyFixture.Tests[0]));
            Assert.That(filter.IsExplicitMatch(_anotherFixture));
            Assert.False(filter.IsExplicitMatch(_anotherFixture.Tests[0]));

            Assert.False(filter.IsExplicitMatch(_yetAnotherFixture));
        }
コード例 #10
0
ファイル: OrFilterTests.cs プロジェクト: stevenaw/nunit
        public void PassTestFullName()
        {
            var filter = new OrFilter(new FullNameFilter(DUMMY_CLASS), new FullNameFilter(ANOTHER_CLASS));

            Assert.That(filter.Pass(_topLevelSuite));
            Assert.That(filter.Pass(_dummyFixture));
            Assert.That(filter.Pass(_dummyFixture.Tests[0]));
            Assert.That(filter.Pass(_anotherFixture));
            Assert.That(filter.Pass(_anotherFixture.Tests[0]));

            Assert.False(filter.Pass(_yetAnotherFixture));
        }
コード例 #11
0
		private TestFilter GetExpression()
		{
			TestFilter term = GetTerm();
			if ( token != "|" )
				return term;

			OrFilter filter = new OrFilter( term );
			
			while ( token == "|" )
			{
				GetToken();
				filter.Add( GetTerm() );
			}

			return filter;
		}
コード例 #12
0
ファイル: OrFilterTests.cs プロジェクト: zzekikaya/nunit
        public void CombineTest(IEnumerable <bool> inputBooleans, bool expectedResult,
                                MockTestFilter.MatchFunction matchFunction)
        {
            var filters = new List <MockTestFilter>();

            foreach (var inputBool in inputBooleans)
            {
                var strictFilter = new MockTestFilter(_dummyFixture, matchFunction, inputBool);
                Assert.AreEqual(inputBool, ExecuteMatchFunction(strictFilter, matchFunction));

                filters.Add(strictFilter);
            }

            var  filter           = new OrFilter(filters.ToArray());
            bool calculatedResult = ExecuteMatchFunction(filter, matchFunction);

            Assert.AreEqual(expectedResult, calculatedResult);
        }
コード例 #13
0
        public void TestNestedOrNotFilters()
        {
            var filter = new OrFilter(
                new CategoryFilter("Dummy"),
                new NotFilter(new CategoryFilter("Dummy")));

            Assert.That(filter.Match(_dummyFixture));
            Assert.That(filter.IsExplicitMatch(_dummyFixture));

            Assert.That(filter.Match(_anotherFixture));
            Assert.False(filter.IsExplicitMatch(_anotherFixture));

            Assert.That(filter.Match(_yetAnotherFixture));
            Assert.False(filter.IsExplicitMatch(_yetAnotherFixture));

            Assert.That(filter.Match(_explicitFixture));
            Assert.False(filter.IsExplicitMatch(_explicitFixture));
        }
コード例 #14
0
        private TestFilter GetExpression()
        {
            TestFilter term = GetTerm();

            if (token != "|")
            {
                return(term);
            }

            OrFilter filter = new OrFilter(term);

            while (token == "|")
            {
                GetToken();
                filter.Add(GetTerm());
            }

            return(filter);
        }
コード例 #15
0
    private static NUnit.Framework.Internal.Filters.OrFilter AddTestToBeRun(TestRunMode testMode)
    {
        NUnit.Framework.Internal.Filters.OrFilter filter = new NUnit.Framework.Internal.Filters.OrFilter();
        switch (testMode)
        {
        case TestRunMode.RunAllTest:
            foreach (var test in AltUnityTesterEditor.EditorConfiguration.MyTests)
            {
                if (!test.IsSuite)
                {
                    filter.Add(new NUnit.Framework.Internal.Filters.FullNameFilter(test.TestName));
                }
            }
            break;

        case TestRunMode.RunSelectedTest:
            foreach (var test in AltUnityTesterEditor.EditorConfiguration.MyTests)
            {
                if (test.Selected && !test.IsSuite)
                {
                    filter.Add(new NUnit.Framework.Internal.Filters.FullNameFilter(test.TestName));
                }
            }
            break;

        case TestRunMode.RunFailedTest:
            foreach (var test in AltUnityTesterEditor.EditorConfiguration.MyTests)
            {
                if (test.Status == -1 && !test.IsSuite)
                {
                    filter.Add(new NUnit.Framework.Internal.Filters.FullNameFilter(test.TestName));
                }
            }
            break;
        }

        return(filter);
    }
コード例 #16
0
ファイル: TestFilter.cs プロジェクト: remcomulder/nunit
        /// <summary>
        /// Create a TestFilter from it's TNode representation
        /// </summary>
        public static TestFilter FromXml(TNode node)
        {
            bool isRegex = node.Attributes["re"] == "1";

            switch (node.Name)
            {
                case "filter":
                case "and":
                    var andFilter = new AndFilter();
                    foreach (var childNode in node.ChildNodes)
                        andFilter.Add(FromXml(childNode));
                    return andFilter;

                case "or":
                    var orFilter = new OrFilter();
                    foreach (var childNode in node.ChildNodes)
                        orFilter.Add(FromXml(childNode));
                    return orFilter;

                case "not":
                    return new NotFilter(FromXml(node.FirstChild));

                case "id":
                    return new IdFilter(node.Value); 

                case "test":
                    return new FullNameFilter(node.Value) { IsRegex = isRegex };

                case "name":
                    return new TestNameFilter(node.Value) { IsRegex = isRegex };

                case "method":
                    return new MethodNameFilter(node.Value) { IsRegex = isRegex };

                case "class":
                    return new ClassNameFilter(node.Value) { IsRegex = isRegex };

                case "cat":
                    return new CategoryFilter(node.Value) { IsRegex = isRegex };

                case "prop":
                    string name = node.Attributes["name"];
                    if (name != null)
                        return new PropertyFilter(name, node.Value) { IsRegex = isRegex };
                    break;
            }

            throw new ArgumentException("Invalid filter element: " + node.Name, "xmlNode");
        }
コード例 #17
0
ファイル: TestFilter.cs プロジェクト: jhsiegel/nunit
        private static TestFilter FromXml(TNode node)
        {
            switch (node.Name)
            {
                case "filter":
                case "and":
                    var andFilter = new AndFilter();
                    foreach (var childNode in node.ChildNodes)
                        andFilter.Add(FromXml(childNode));
                    return andFilter;

                case "or":
                    var orFilter = new OrFilter();
                    foreach (var childNode in node.ChildNodes)
                        orFilter.Add(FromXml(childNode));
                    return orFilter;

                case "not":
                    return new NotFilter(FromXml(node.FirstChild));

                case "id":
                    var idFilter = new IdFilter();
                    if (node.Value != null)
                        foreach (string id in node.Value.Split(COMMA))
                            idFilter.Add(id);
                    return idFilter;

                case "tests":
                    var testFilter = new SimpleNameFilter();
                    foreach (var childNode in node.SelectNodes("test"))
                        testFilter.Add(childNode.Value);
                    return testFilter;

                case "cat":
                    var catFilter = new CategoryFilter();
                    if (node.Value != null)
                        foreach (string cat in node.Value.Split(COMMA))
                            catFilter.AddCategory(cat);
                    return catFilter;

                default:
                    throw new ArgumentException("Invalid filter element: " + node.Name, "xmlNode");
            }
        }
コード例 #18
0
ファイル: OrFilterTests.cs プロジェクト: nunit/nunit
        public void IsNotEmpty()
        {
            var filter = new OrFilter(new CategoryFilter("Dummy"), new CategoryFilter("Another"));

            Assert.False(filter.IsEmpty);
        }
コード例 #19
0
ファイル: TestFilterTests.cs プロジェクト: JohanLarsson/nunit
        public void OrFilter_Constructor()
        {
            var filter = new OrFilter(new CategoryFilter("Dummy"), new CategoryFilter("Another"));

            Assert.False(filter.IsEmpty);
            Assert.That(filter.Match(dummyFixture));
            Assert.That(filter.Match(anotherFixture));
        }
コード例 #20
0
ファイル: OrFilterTests.cs プロジェクト: zzekikaya/nunit
        public void IsNotEmpty()
        {
            var filter = new OrFilter(new CategoryFilter("Dummy"), new CategoryFilter("Another"));

            Assert.False(filter.IsEmpty);
        }
コード例 #21
0
ファイル: OrFilterTests.cs プロジェクト: stevenaw/nunit
        public void IsNotEmptyFullName()
        {
            var filter = new OrFilter(new FullNameFilter("Dummy"), new FullNameFilter("Another"));

            Assert.False(filter.IsEmpty);
        }
コード例 #22
0
ファイル: OrFilterTests.cs プロジェクト: nunit/nunit
        public void CombineTest(IEnumerable<bool> inputBooleans, bool expectedResult,
            MockTestFilter.MatchFunction matchFunction)
        {
            var filters = new List<MockTestFilter>();
            foreach (var inputBool in inputBooleans)
            {
                var strictFilter = new MockTestFilter(_dummyFixture, matchFunction, inputBool);
                Assert.AreEqual(inputBool, ExecuteMatchFunction(strictFilter, matchFunction));

                filters.Add(strictFilter);
            }

            var filter = new OrFilter(filters.ToArray());
            bool calculatedResult = ExecuteMatchFunction(filter, matchFunction);
            Assert.AreEqual(expectedResult, calculatedResult);
        }
コード例 #23
0
        private static TestFilter FromXml(XmlNode xmlNode)
        {
            switch (xmlNode.Name)
            {
                case "filter":
                case "and":
                    var andFilter = new AndFilter();
                    foreach (XmlNode childNode in xmlNode.ChildNodes)
                        andFilter.Add(FromXml(childNode));
                    return andFilter;

                case "or":
                    var orFilter = new OrFilter();
                    foreach (System.Xml.XmlNode childNode in xmlNode.ChildNodes)
                        orFilter.Add(FromXml(childNode));
                    return orFilter;

                case "not":
                    return new NotFilter(FromXml(xmlNode.FirstChild));

                case "id":
                    var idFilter = new IdFilter();
                    foreach (string id in xmlNode.InnerText.Split(COMMA))
                        idFilter.Add(int.Parse(id));
                    return idFilter;

                case "tests":
                    var testFilter = new SimpleNameFilter();
                    foreach (XmlNode childNode in xmlNode.SelectNodes("test"))
                        testFilter.Add(childNode.InnerText);
                    return testFilter;

                case "cat":
                    var catFilter = new CategoryFilter();
                    foreach (string cat in xmlNode.InnerText.Split(COMMA))
                        catFilter.AddCategory(cat);
                    return catFilter;

                default:
                    throw new ArgumentException("Invalid filter element: " + xmlNode.Name, "xmlNode");
            }
        }