maven-surefire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From krosenv...@apache.org
Subject svn commit: r1051545 - in /maven/surefire/trunk/surefire-providers/surefire-junit4/src: main/java/org/apache/maven/surefire/junit4/JUnit4TestChecker.java test/java/org/apache/maven/surefire/junit4/JUnit4TestCheckerTest.java
Date Tue, 21 Dec 2010 16:32:30 GMT
Author: krosenvold
Date: Tue Dec 21 16:32:30 2010
New Revision: 1051545

URL: http://svn.apache.org/viewvc?rev=1051545&view=rev
Log:
[SUREFIRE-671] Junit4.x tries to run abstract testcases

Modified:
    maven/surefire/trunk/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4TestChecker.java
    maven/surefire/trunk/surefire-providers/surefire-junit4/src/test/java/org/apache/maven/surefire/junit4/JUnit4TestCheckerTest.java

Modified: maven/surefire/trunk/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4TestChecker.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4TestChecker.java?rev=1051545&r1=1051544&r2=1051545&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4TestChecker.java
(original)
+++ maven/surefire/trunk/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4TestChecker.java
Tue Dec 21 16:32:30 2010
@@ -19,6 +19,7 @@ package org.apache.maven.surefire.junit4
  * under the License.
  */
 
+import org.apache.maven.surefire.NonAbstractClassFilter;
 import org.apache.maven.surefire.util.ReflectionUtils;
 import org.apache.maven.surefire.util.ScannerFilter;
 
@@ -33,12 +34,15 @@ public class JUnit4TestChecker
 {
     private final Class junitClass;
 
+    private final NonAbstractClassFilter nonAbstractClassFilter;
+
     private final Class runWith;
 
     public JUnit4TestChecker( ClassLoader testClassLoader )
     {
         this.junitClass = getJUnitClass( testClassLoader, junit.framework.Test.class.getName()
);
         this.runWith = getJUnitClass( testClassLoader, org.junit.runner.RunWith.class.getName()
);
+        this.nonAbstractClassFilter = new NonAbstractClassFilter();
     }
 
     public boolean accept( Class testClass )
@@ -49,6 +53,10 @@ public class JUnit4TestChecker
     @SuppressWarnings( { "unchecked" } )
     public boolean isValidJUnit4Test( Class testClass )
     {
+        if ( !nonAbstractClassFilter.accept( testClass ) )
+        {
+            return false;
+        }
         if ( junitClass != null && junitClass.isAssignableFrom( testClass ) )
         {
             return true;

Modified: maven/surefire/trunk/surefire-providers/surefire-junit4/src/test/java/org/apache/maven/surefire/junit4/JUnit4TestCheckerTest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-junit4/src/test/java/org/apache/maven/surefire/junit4/JUnit4TestCheckerTest.java?rev=1051545&r1=1051544&r2=1051545&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-providers/surefire-junit4/src/test/java/org/apache/maven/surefire/junit4/JUnit4TestCheckerTest.java
(original)
+++ maven/surefire/trunk/surefire-providers/surefire-junit4/src/test/java/org/apache/maven/surefire/junit4/JUnit4TestCheckerTest.java
Tue Dec 21 16:32:30 2010
@@ -86,6 +86,11 @@ public class JUnit4TestCheckerTest
         assertFalse( jUnit4TestChecker.isValidJUnit4Test( NotValidTest.class ) );
     }
 
+    @Test
+    public void dontAcceptAbstractClasses(){
+        assertFalse( jUnit4TestChecker.isValidJUnit4Test( BaseClassWithTest.class ) );
+    }
+
 
     public static class AlsoValid
         extends TestCase



Mime
View raw message