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); } }
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); }
private TestFilter GetExpression() { TestFilter term = GetTerm(); if ( token != "|" ) return term; OrFilter filter = new OrFilter( term ); while ( token == "|" ) { GetToken(); filter.Add( GetTerm() ); } return filter; }
private TestFilter GetExpression() { TestFilter term = GetTerm(); if (token != "|") { return(term); } OrFilter filter = new OrFilter(term); while (token == "|") { GetToken(); filter.Add(GetTerm()); } return(filter); }
/// <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"); }
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"); } }
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"); } }