You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by "Campano, Troy" <Tr...@LibertyMutual.com> on 2008/04/30 02:14:28 UTC

Execute Integration/Unit Tests Separately

Hello, 
I am new to Maven 2 (trying to convert from Maven 1). I want to be able
to run my Unit Tests and Integration Tests separately. I have named my
unit tests **UnitTest.java and my integration tests
**IntegrationTest.java. In Maven 1 I would define two custom goals in
maven.xml, one for each type of test, and also define the "include"
filter to include the correct tests in the corresponding custom goal
(the "test-unit" goal would run all my **UnitTest.java files and
"test-integration" would run all of my **IntegrationTest.java files).

How do I do this with Maven 2? I just read through the whole "lifecycle"
concept. Does this mean I would define the SureFire plugin to run in the
"test" phase and the "integration-test" phase and each definition in my
pom.xml would be tied to one of those lifecycle phases (each with their
own separate "include" definition)?

Thank you for the help, it's appreciated!

~ T r o y ~ 

RE: Execute Integration/Unit Tests Separately

Posted by "Campano, Troy" <Tr...@LibertyMutual.com>.
Great, thank you David. I also found some related information here:
http://wiki.rodcoffin.com/index.php?title=Maven_Integration_Testing

~ T r o y ~


-----Original Message-----
From: Bernhard David [mailto:david.bernhard@elca.ch] 
Sent: Wednesday, April 30, 2008 2:54 AM
To: Maven Users List
Subject: RE: Execute Integration/Unit Tests Separately

Hello,

unit tests we just put in src/test/java instead of src/main/java and
surefire runs them automatically in phase "test". You can do a "mvn
test" on the command-line to run only up to and including these tests. 

Integration tests - here's an example (that you can also adapt for unit
tests)

<plugin>
	<groupId>org.apache.maven.plugins</groupId>
	<artifactId>maven-surefire-plugin</artifactId>
	<executions>
		<execution>
			<id>integration-tests</id>
			<phase>integration-test</phase>
			<goals>
				<goal>test</goal>
			</goals>
			<configuration>
				<includes>
	
<param>**/*IntegrationTest.java</param>
				</includes>
			</configuration>
		</execution>
	</executions>
</plugin>

They'll be run in the regular build in phase integration-test. If you
don't want them to run automatically, you can put this in a <profile>
section and then you'd start them with "mvn -P profilename
integration-test".

Yours,

David


> -----Original Message-----
> From: Campano, Troy [mailto:Troy.Campano@LibertyMutual.com] 
> Sent: 30 April 2008 02:14
> To: users@maven.apache.org
> Subject: Execute Integration/Unit Tests Separately
> 
> 
> Hello, 
> I am new to Maven 2 (trying to convert from Maven 1). I want 
> to be able
> to run my Unit Tests and Integration Tests separately. I have named my
> unit tests **UnitTest.java and my integration tests
> **IntegrationTest.java. In Maven 1 I would define two custom goals in
> maven.xml, one for each type of test, and also define the "include"
> filter to include the correct tests in the corresponding custom goal
> (the "test-unit" goal would run all my **UnitTest.java files and
> "test-integration" would run all of my **IntegrationTest.java files).
> 
> How do I do this with Maven 2? I just read through the whole 
> "lifecycle"
> concept. Does this mean I would define the SureFire plugin to 
> run in the
> "test" phase and the "integration-test" phase and each 
> definition in my
> pom.xml would be tied to one of those lifecycle phases (each 
> with their
> own separate "include" definition)?
> 
> Thank you for the help, it's appreciated!
> 
> ~ T r o y ~ 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


RE: Execute Integration/Unit Tests Separately

Posted by Bernhard David <da...@elca.ch>.
Hello,

unit tests we just put in src/test/java instead of src/main/java and
surefire runs them automatically in phase "test". You can do a "mvn
test" on the command-line to run only up to and including these tests. 

Integration tests - here's an example (that you can also adapt for unit
tests)

<plugin>
	<groupId>org.apache.maven.plugins</groupId>
	<artifactId>maven-surefire-plugin</artifactId>
	<executions>
		<execution>
			<id>integration-tests</id>
			<phase>integration-test</phase>
			<goals>
				<goal>test</goal>
			</goals>
			<configuration>
				<includes>
	
<param>**/*IntegrationTest.java</param>
				</includes>
			</configuration>
		</execution>
	</executions>
</plugin>

They'll be run in the regular build in phase integration-test. If you
don't want them to run automatically, you can put this in a <profile>
section and then you'd start them with "mvn -P profilename
integration-test".

Yours,

David


> -----Original Message-----
> From: Campano, Troy [mailto:Troy.Campano@LibertyMutual.com] 
> Sent: 30 April 2008 02:14
> To: users@maven.apache.org
> Subject: Execute Integration/Unit Tests Separately
> 
> 
> Hello, 
> I am new to Maven 2 (trying to convert from Maven 1). I want 
> to be able
> to run my Unit Tests and Integration Tests separately. I have named my
> unit tests **UnitTest.java and my integration tests
> **IntegrationTest.java. In Maven 1 I would define two custom goals in
> maven.xml, one for each type of test, and also define the "include"
> filter to include the correct tests in the corresponding custom goal
> (the "test-unit" goal would run all my **UnitTest.java files and
> "test-integration" would run all of my **IntegrationTest.java files).
> 
> How do I do this with Maven 2? I just read through the whole 
> "lifecycle"
> concept. Does this mean I would define the SureFire plugin to 
> run in the
> "test" phase and the "integration-test" phase and each 
> definition in my
> pom.xml would be tied to one of those lifecycle phases (each 
> with their
> own separate "include" definition)?
> 
> Thank you for the help, it's appreciated!
> 
> ~ T r o y ~ 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org