Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'mcs/nunit/src/NUnitCore/LoadingTestCollector.cs')
-rw-r--r--mcs/nunit/src/NUnitCore/LoadingTestCollector.cs113
1 files changed, 48 insertions, 65 deletions
diff --git a/mcs/nunit/src/NUnitCore/LoadingTestCollector.cs b/mcs/nunit/src/NUnitCore/LoadingTestCollector.cs
index 63ac74ef5f0..4938ee952e9 100644
--- a/mcs/nunit/src/NUnitCore/LoadingTestCollector.cs
+++ b/mcs/nunit/src/NUnitCore/LoadingTestCollector.cs
@@ -1,71 +1,54 @@
-namespace NUnit.Runner {
+namespace NUnit.Runner
+{
+ using System;
+ using System.Reflection;
+ using NUnit.Framework;
- using System;
- using System.Reflection;
-
- using NUnit.Framework;
-
- /// <summary>
- /// An implementation of a TestCollector that loads
- /// all classes on the class path and tests whether
- /// it is assignable from ITest or provides a static Suite property.
- /// <see cref="ITestCollector"/>
- /// </summary>
- public class LoadingClassPathTestCollector: ClassPathTestCollector {
-
- TestCaseClassLoader fLoader;
/// <summary>
- ///
+ /// An implementation of a TestCollector that loads
+ /// all classes on the class path and tests whether
+ /// it is assignable from ITest or provides a static Suite property.
+ /// <see cref="ITestCollector"/>
/// </summary>
- public LoadingClassPathTestCollector() {
- fLoader= new TestCaseClassLoader();
- }
- /// <summary>
- ///
- /// </summary>
- /// <param name="classFileName"></param>
- /// <returns></returns>
- protected override bool IsTestClass(string classFileName) {
- try {
- if (classFileName.EndsWith(".dll") || classFileName.EndsWith(".exe")) {
- Type testClass= ClassFromFile(classFileName);
- return (testClass != null) && IsTestClass(testClass);
- }
- } catch (TypeLoadException) {
- }
- return false;
- }
-
- Type ClassFromFile(string classFileName) {
- string className= ClassNameFromFile(classFileName);
- if (!fLoader.IsExcluded(className))
- return fLoader.LoadClass(className, false);
- return null;
- }
-
- bool IsTestClass(Type testClass) {
- if (HasSuiteMethod(testClass))
- return true;
- if (typeof(ITest).IsAssignableFrom(testClass) &&
- testClass.IsPublic &&
- HasPublicConstructor(testClass))
- return true;
- return false;
- }
+ [Obsolete("Use StandardLoader or UnloadingLoader")]
+ public class LoadingClassPathTestCollector: ClassPathTestCollector
+ {
- bool HasSuiteMethod(Type testClass) {
- return (testClass.GetProperty(BaseTestRunner.SUITE_PROPERTYNAME, new Type[0]) == null);
- }
+ TestCaseClassLoader fLoader;
+ /// <summary>
+ ///
+ /// </summary>
+ public LoadingClassPathTestCollector()
+ {
+ fLoader= new TestCaseClassLoader();
+ }
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="classFileName"></param>
+ /// <returns></returns>
+ protected override bool IsTestClass(string classFileName)
+ {
+ try
+ {
+ if (classFileName.EndsWith(".dll") || classFileName.EndsWith(".exe"))
+ {
+ Type testClass= ClassFromFile(classFileName);
+ return (testClass != null); //HACK: && TestCase.IsTest(testClass);
+ }
+ }
+ catch (TypeLoadException)
+ {
+ }
+ return false;
+ }
- bool HasPublicConstructor(Type testClass) {
- Type[] args= { typeof(string) };
- ConstructorInfo c= null;
- try {
- c= testClass.GetConstructor(args);
- } catch(Exception) {
- return false;
- }
- return true;
- }
- }
+ private Type ClassFromFile(string classFileName)
+ {
+ string className = base.ClassNameFromFile(classFileName);
+ if (!fLoader.IsExcluded(className))
+ return fLoader.LoadClass(className, false);
+ return null;
+ }
+ }
} \ No newline at end of file