You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Marvin Froeder (JIRA)" <ji...@codehaus.org> on 2010/08/25 19:46:32 UTC

[jira] Created: (SUREFIRE-642) TestNG support doesn't w/o Junit on classpath

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

        

[jira] Issue Comment Edited: (SUREFIRE-642) TestNG support doesn't w/o Junit on classpath

Posted by "Marvin Froeder (JIRA)" <ji...@codehaus.org>.
    [ 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

        

[jira] Commented: (SUREFIRE-642) TestNG support doesn't w/o Junit on classpath

Posted by "Marvin Froeder (JIRA)" <ji...@codehaus.org>.
    [ http://jira.codehaus.org/browse/SUREFIRE-642?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=233126#action_233126 ] 

Marvin Froeder commented on SUREFIRE-642:
-----------------------------------------

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

        

[jira] Closed: (SUREFIRE-642) TestNG support doesn't w/o Junit on classpath

Posted by "Benjamin Bentmann (JIRA)" <ji...@codehaus.org>.
     [ http://jira.codehaus.org/browse/SUREFIRE-642?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Benjamin Bentmann closed SUREFIRE-642.
--------------------------------------

       Resolution: Fixed
    Fix Version/s: 2.7
         Assignee: Benjamin Bentmann

Applied in [r989300|http://svn.apache.org/viewvc?view=revision&revision=989300], thanks!

> 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
>            Assignee: Benjamin Bentmann
>             Fix For: 2.7
>
>
> 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