maven-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Marvin Froeder (JIRA)" <j...@codehaus.org>
Subject [jira] Issue Comment Edited: (SUREFIRE-642) TestNG support doesn't w/o Junit on classpath
Date Wed, 25 Aug 2010 18:37:32 GMT

    [ http://jira.codehaus.org/browse/SUREFIRE-642?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=233126#action_233126
] 

Marvin Froeder edited comment on SUREFIRE-642 at 8/25/10 1:37 PM:
------------------------------------------------------------------

I made a small patch for it, I hope a 2.6.1 could carry this fix.

{code}
Index: surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGDirectoryTestSuite.java
===================================================================
--- surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGDirectoryTestSuite.java
(revision 989255)
+++ surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGDirectoryTestSuite.java
(working copy)
@@ -115,13 +115,24 @@
             throw new IllegalStateException( "You must call locateTestSets before calling
execute" );
         }
 
+        Class junitTest;
+        try
+        {
+            junitTest = Class.forName( "junit.framework.Test" );
+        }
+        catch ( ClassNotFoundException e )
+        {
+            junitTest = null;
+        }
+
         List testNgTestClasses = new ArrayList();
         List junitTestClasses = new ArrayList();
         for ( Iterator it = testSets.values().iterator(); it.hasNext(); )
         {
             SurefireTestSet testSet = (SurefireTestSet) it.next();
             Class c = testSet.getTestClass();
-            if (junit.framework.Test.class.isAssignableFrom( c )) {
+            if ( junitTest != null && junitTest.isAssignableFrom( c ) )
+            {
                 junitTestClasses.add( c );
             } else {
                 testNgTestClasses.add( c );
Index: surefire-integration-tests/src/test/resources/testng-simple/pom.xml
===================================================================
--- surefire-integration-tests/src/test/resources/testng-simple/pom.xml	(revision 989255)
+++ surefire-integration-tests/src/test/resources/testng-simple/pom.xml	(working copy)
@@ -39,6 +39,12 @@
       <version>${testNgVersion}</version>
       <classifier>jdk15</classifier>
       <scope>test</scope>
+      <exclusions>
+        <exclusion>
+          <groupId>junit</groupId>
+          <artifactId>junit</artifactId>
+        </exclusion>
+      </exclusions>
     </dependency>
   </dependencies>
{code}

I tamper with testng-simple so it can catch the issue

      was (Author: velo):
    I made a small patch for it, I hope a 2.6.1 could carry this fix.

{code}
Index: src/main/java/org/apache/maven/surefire/testng/TestNGDirectoryTestSuite.java
===================================================================
--- src/main/java/org/apache/maven/surefire/testng/TestNGDirectoryTestSuite.java	(revision
989255)
+++ src/main/java/org/apache/maven/surefire/testng/TestNGDirectoryTestSuite.java	(working
copy)
@@ -29,13 +29,6 @@
 
 import org.apache.maven.artifact.versioning.ArtifactVersion;
 import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
-import org.apache.maven.surefire.report.ReportEntry;
-import org.apache.maven.surefire.report.ReporterException;
-import org.apache.maven.surefire.report.ReporterManager;
-import org.apache.maven.surefire.report.ReporterManagerFactory;
-import org.apache.maven.surefire.suite.AbstractDirectoryTestSuite;
-import org.apache.maven.surefire.testset.SurefireTestSet;
-import org.apache.maven.surefire.testset.TestSetFailedException;
 
 /**
  * Test suite for TestNG based on a directory of Java test classes. Can also execute JUnit
tests.
@@ -115,13 +108,24 @@
             throw new IllegalStateException( "You must call locateTestSets before calling
execute" );
         }
 
+        Class junitTest;
+        try
+        {
+            junitTest = Class.forName( "junit.framework.Test" );
+        }
+        catch ( ClassNotFoundException e )
+        {
+            junitTest = null;
+        }
+
         List testNgTestClasses = new ArrayList();
         List junitTestClasses = new ArrayList();
         for ( Iterator it = testSets.values().iterator(); it.hasNext(); )
         {
             SurefireTestSet testSet = (SurefireTestSet) it.next();
             Class c = testSet.getTestClass();
-            if (junit.framework.Test.class.isAssignableFrom( c )) {
+            if ( junitTest != null && junitTest.isAssignableFrom( c ) )
+            {
                 junitTestClasses.add( c );
             } else {
                 testNgTestClasses.add( c );

{code}
  
> TestNG support doesn't w/o Junit on classpath
> ---------------------------------------------
>
>                 Key: SUREFIRE-642
>                 URL: http://jira.codehaus.org/browse/SUREFIRE-642
>             Project: Maven Surefire
>          Issue Type: Bug
>          Components: TestNG support
>    Affects Versions: 2.6
>            Reporter: Marvin Froeder
>
> I have the same problem that Larry reported here:
> http://jira.codehaus.org/browse/SUREFIRE-615?focusedCommentId=232600&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#action_232600
> Our company excludes junit from classpath to make sure people won't use it by mistake.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message