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

James Kato commented on SUREFIRE-377:
-------------------------------------

Hi,
I am trying to run both JUnit 4.4 and TestNG 5.8 tests in the same suite. I 
seem to have come accross this problem in surefire 2.4.3 where as soon as I add 
testNG as a dependency, the TestNG runner is used. The problem is that this 
runner cannot handle JUnit 4.4 tests: I get: 

Running TestSuite
org.testng.TestNGException: 
Failure in JUnit mode for class com.sampleTest: could not create/run JUnit test 
suite: 
cannot retrieve JUnit method

Which is resolved if I extend TestCase in com.sampleTest as in JUnit 3.x

A sample of the pom.xml I use is:

<dependencies>
<dependency> 
        <groupId>org.testng</groupId>
        <artifactId>testng</artifactId>
        <version>5.8</version>
        <scope>test</scope>
        <classifier>jdk15</classifier>
    </dependency> 
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
                <version>4.4</version>
                <scope>test</scope>
    </dependency>
</dependencies>
<build>
    <plugins>
      <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.4.3</version>
                <configuration>
                    <properties>
                                <property>
                                        <name>junit</name>
                                        <value>true</value>
                                </property>
                        </properties> 
                </configuration>
      </plugin>
    </plugins>
  </build>

Note, at present I would be happy to run all JUnit 4.4 tests in one execution 
and then use a profile to run all TestNG tests.

Please can you tell me whether you know of a work around for this?

Cheers,
James

> When JUnit and TestNG tests are in same project, only one set gets run
> ----------------------------------------------------------------------
>
>                 Key: SUREFIRE-377
>                 URL: http://jira.codehaus.org/browse/SUREFIRE-377
>             Project: Maven Surefire
>          Issue Type: Bug
>          Components: TestNG support
>    Affects Versions: 2.4
>            Reporter: Dan Fabulich
>             Fix For: 2.4
>
>         Attachments: surefire377.patch, testng-junit-together.zip
>
>
> The attached Maven project has two tests: one JUnit test and one TestNG test. 
>  According to the documentation, in this case TestNG should run both tests.
> Run "mvn test".  Only the TestNG test will run.  If you modify the pom to set 
> the property "junit=true", only the JUnit test will run.
> <plugin>
>   <groupId>org.apache.maven.plugins</groupId>
>   <artifactId>maven-surefire-plugin</artifactId>
>   <version>2.4-SNAPSHOT</version>
>   <configuration>
>     <properties>
>       <property>
>         <name>junit</name>
>         <value>true</value>
>       </property>
>     </properties>
> </plugin>

-- 
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

        

Reply via email to