private void FilterByRuntimeVersion(IList <ITestClass> classes, TestClassInstanceDictionary instances) { List <ITestClass> emptyTests = new List <ITestClass>(); foreach (ITestClass test in classes) { object instance = instances.GetInstance(test.Type); ICollection <ITestMethod> methods = GetTestMethods(test, instance); FilterByRuntimeVersion(methods); if (methods.Count == 0) { emptyTests.Add(test); } } if (emptyTests.Count > 0) { foreach (ITestClass test in emptyTests) { classes.Remove(test); } } }
/// <summary> /// Apply tag filtering. /// </summary> /// <param name="classes">List of test classes.</param> /// <param name="instances">Test class instance dictionary.</param> protected internal override void FilterCustomTestClasses(IList <ITestClass> classes, TestClassInstanceDictionary instances) { if (string.IsNullOrEmpty(TagExpression)) { return; } // Temporarily apply to the methods as well. If the class has no // methods that were matched in the expression, then cut the // class from the run. List <ITestClass> emptyTests = new List <ITestClass>(); foreach (ITestClass test in classes) { object instance = instances.GetInstance(test.Type); ICollection <ITestMethod> methods = GetTestMethods(test, instance); TagManager tm = new TagManager(test.Type, methods); ApplyExpression(tm, methods); if (methods.Count == 0) { emptyTests.Add(test); } } if (emptyTests.Count > 0) { foreach (ITestClass test in emptyTests) { classes.Remove(test); } } if (!_hasLoggedWarning) { UnitTestHarness.LogWriter.Information(string.Format(CultureInfo.InvariantCulture, Properties.UnitTestMessage.TagTestRunFilter_TaggingInUse, TagExpression)); _hasLoggedWarning = true; } }