You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Aleksei Valikov (JIRA)" <ji...@codehaus.org> on 2010/03/29 00:25:23 UTC

[jira] Issue Comment Edited: (SUREFIRE-377) When JUnit and TestNG tests are in same project, only one set gets run

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

Aleksei Valikov edited comment on SUREFIRE-377 at 3/28/10 5:23 PM:
-------------------------------------------------------------------

I have a [better solution|http://confluence.highsource.org/display/~lexi/How+to+run+both+JUnit+and+TestNG+with+maven-surefire-plugin].

The idea is to create two executions of the maven-surefire-plugin, one for JUnit, one for TestNG. You can disable one of JUnit/TestNG per execution by specifying nonexisting {{junitArtifactName}} or {{testNGArtifactName}}:

{code:xml}
<plugin>
	<groupId>org.apache.maven.plugins</groupId>
	<artifactId>maven-surefire-plugin</artifactId>
	<executions>
		<execution>
			<phase>test</phase>
			<goals>
				<goal>test</goal>
			</goals>
			<configuration>	
				<testNGArtifactName>none:none</testNGArtifactName>
			</configuration>
		</execution>
		<execution>
			<id>test-testng</id>
			<phase>test</phase>
			<goals>
				<goal>test</goal>
			</goals>
			<configuration>	
				<junitArtifactName>none:none</junitArtifactName>
			</configuration>
		</execution>
	</executions>
</plugin>
{code}

      was (Author: lexicore):
    I have a better solution.

The idea is to create two executions of the maven-surefire-plugin, one for JUnit, one for TestNG. You can disable one of JUnit/TestNG per execution by specifying nonexisting {{junitArtifactName}} or {{testNGArtifactName}}:

{code:xml}
<plugin>
	<groupId>org.apache.maven.plugins</groupId>
	<artifactId>maven-surefire-plugin</artifactId>
	<executions>
		<execution>
			<phase>test</phase>
			<goals>
				<goal>test</goal>
			</goals>
			<configuration>	
				<testNGArtifactName>none:none</testNGArtifactName>
			</configuration>
		</execution>
		<execution>
			<id>test-testng</id>
			<phase>test</phase>
			<goals>
				<goal>test</goal>
			</goals>
			<configuration>	
				<junitArtifactName>none:none</junitArtifactName>
			</configuration>
		</execution>
	</executions>
</plugin>
{code}
  
> 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