You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Steve Hayes <st...@cogentconsulting.com.au> on 2007/03/05 08:48:55 UTC

Running surefire for test and integration-test and producing two reports

Hi,

I have just started using Maven2, and I think that I am missing  
something fundamental. I am trying to create a build that:

1) Runs some tests as unit tests during the test phase;
2) Runs some other tests as integration tests during the integration- 
test phase;
3) Produces two surefire reports on the site

I have tried a number of different approaches, and all of them have  
had something wrong. I have tried using the <executions> to bind the  
unit and integration tests to different phases and goals, but there  
also seems to be some default behaviour invoked which executes all my  
tests, without reference to the <executions>, when the surefire:test  
target in invoked as a dependency. I would like to see two test runs,  
but I always end up seeing more than that.

And when I run the site goal, the unit tests are executed but the  
integration tests are not.

I'm working with a simple project with just dummy code and tests in  
it, so the problem is unlikely to be the complexity of my project.

Can anyone point me to an example that does something like that I'm  
after?

Regards,
Steve Hayes

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


Re: Running surefire for test and integration-test and producing two reports

Posted by Pete <pe...@gmail.com>.
Steve,

I've had the same issue myself regarding the integration test JUnits
not appearing in the site,  what I found was it doesn't matter what is
put in the <reporting> section of the pom regarding configuring the
'maven-surefire-plugin' itself.

Instead Maven seems to use the 'maven-surefire-plugin' configuration
from the <build> section EVEN when doing a 'site' goal.

So I did have the <build> configuration like this, meaning Test.java
get run during 'test' phase and ITTest.java only get run for
'integration-test' phase. This works fine during build but not for
'site'.

So the only hack I can find is to
make the exclude alterable during 'site' or 'test' , see 2nd example

<plugin>
	<groupId>org.apache.maven.plugins</groupId>
	<artifactId>maven-surefire-plugin</artifactId>
	<version>2.3</version>
	<!--  default configuration for default 'test' phase  bindings -->
	<configuration>
		<reportFormat>xml</reportFormat>
		<forkMode>none</forkMode>
		
		<includes>
			<include>**/*Test.java</include>
		</includes>
		<excludes>
			<exclude>${exclude.pattern.it.tests}</exclude>
		</excludes>
	</configuration>
	<!-- special configuration to pick up src/it/java during
integration-test phase -->
	<executions>
		<execution>
			<id>surefire-it</id>
			<phase>integration-test</phase>
			<configuration>
				<includes>
					<include>**/*ITTest.java</include>
				</includes>
			</configuration>
			<goals>
				<goal>test</goal>
			</goals>
		</execution>
	</executions>
</plugin>

What follows in a 2nd version to make site work, with
${exclude.pattern.it.tests} set by default in pom to

<exclude.pattern.it.tests>**/*ITTest.java</exclude.pattern.it.tests>

so this is used to exclude during a normal 'mvn test'

but when site is run I have to include the above e.g

mvn site -Dexclude.pattern.it.tests=anyoldstring

<plugin>
	<groupId>org.apache.maven.plugins</groupId>
	<artifactId>maven-surefire-plugin</artifactId>
	<version>2.3</version>
	<!--  default configuration for default 'test' phase  bindings -->
	<configuration>
		<reportFormat>xml</reportFormat>
		<forkMode>none</forkMode>
		
		<includes>
			<include>**/*Test.java</include>
		</includes>
		<excludes>
			<exclude>${exclude.pattern.it.tests}</exclude>   <!-- to exclude
'**/*ITTest.java' during 'test' but not during 'site' so this is
variable -->
		</excludes>
	</configuration>
	<!-- special configuration to pick up src/it/java during
integration-test phase -->
	<executions>
		<execution>
			<id>surefire-it</id>
			<phase>integration-test</phase>
			<configuration>
				<includes>
					<include>**/*ITTest.java</include>
				</includes>
			</configuration>
			<goals>
				<goal>test</goal>
			</goals>
		</execution>
	</executions>
</plugin>

However this means the integration tests get run during the 'test'
phase when running 'site' instead of 'integration-test' so it's not
ideal.

Anyone else help ?

Pete

On 05/03/07, Steve Hayes <st...@cogentconsulting.com.au> wrote:
> Hi,
>
> I have just started using Maven2, and I think that I am missing
> something fundamental. I am trying to create a build that:
>
> 1) Runs some tests as unit tests during the test phase;
> 2) Runs some other tests as integration tests during the integration-
> test phase;
> 3) Produces two surefire reports on the site
>
> I have tried a number of different approaches, and all of them have
> had something wrong. I have tried using the <executions> to bind the
> unit and integration tests to different phases and goals, but there
> also seems to be some default behaviour invoked which executes all my
> tests, without reference to the <executions>, when the surefire:test
> target in invoked as a dependency. I would like to see two test runs,
> but I always end up seeing more than that.
>
> And when I run the site goal, the unit tests are executed but the
> integration tests are not.
>
> I'm working with a simple project with just dummy code and tests in
> it, so the problem is unlikely to be the complexity of my project.
>
> Can anyone point me to an example that does something like that I'm
> after?
>
> Regards,
> Steve Hayes
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

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