You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Kristof Vanbecelaere <kr...@gmail.com> on 2008/11/27 20:37:41 UTC

maven-surefire-plugin configuration for unit/integration tests

Hello,

I found this interesting blog:

http://weblogs.java.net/blog/johnsmart/archive/2008/06/unit_tests_are.html

Unfortunately, I failed to make it work. When running mvn integration-test
all unit tests get to run before running the integration tests, which is not
really the aim. The idea really is to be able to either run unit tests or
integration tests but not both at the same time. Any ideas why this fails?

I guess the only real way (still) to split off integration tests is to have
a separate module wherein to place these integration tests and put no unit
tests in said module. Or is there?

Thanks.
-- 
View this message in context: http://www.nabble.com/maven-surefire-plugin-configuration-for-unit-integration-tests-tp20724622p20724622.html
Sent from the Maven - Users mailing list archive at Nabble.com.


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


Re: maven-surefire-plugin configuration for unit/integration tests

Posted by Stephen Connolly <st...@gmail.com>.
That is why I run the individual tests from my IDE.

My IDE (IntelliJ)

2008/11/28 Kristof Vanbecelaere <kr...@gmail.com>

>
> Maybe I need to rephrase this a bit. Your line of reasoning is absolutely
> correct from a process point of view (like a CI build). But rigorously
> applying this principle across the board denies developers the comfort of
> selectively running subsets of tests. Developer productivity should count
> for something as well.
>
>
> Kristof Vanbecelaere wrote:
> >
> > I disagree. Have you ever written a selenium test? This is trial and
> > error. I have not touched any "real" code, only test code. So I know my
> > unit tests succeed. All I want to do is run the integration-test phase
> > without unit tests.
> >
> >
> > Stephen Connolly-2 wrote:
> >>
> >> 2008/11/27 Kristof Vanbecelaere <kr...@gmail.com>
> >>
> >> Actually, that is the aim.
> >>
> >> You run all the unit tests to make sure that the code is good enough to
> >> try
> >> and run the integration tests.
> >>
> >> If your unit tests fail, your code is broken and you know it, so fix
> your
> >> code.
> >>
> >> If your unit tests pass, now lets see if it integrates correctly, hence
> >> run
> >> the integration tests.
> >>
> >> If the integration tests pass, we can publish the project (i.e. install
> >> or
> >> deploy to maven repo)
> >>
> >> This is what the lifecycle is all about... a well defined sequence of
> >> phases, all the previous phases must complete successfully before the
> >> next
> >> phase starts.
> >>
> >>
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/maven-surefire-plugin-configuration-for-unit-integration-tests-tp20724622p20730746.html
> Sent from the Maven - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: maven-surefire-plugin configuration for unit/integration tests

Posted by Willllllll <wi...@gmail.com>.
I agree: if you haven't changed any code, and you haven't changed any unit
tests, then the only tests that need to run are the integration tests that
you are changing. If you've made a mistake and have changed application or
unit test code, your CI process will (should) pick it up.

We use maven code like 
	<execution>
		<id>generate-hbm-files</id>
		<phase>generate-resources</phase>
		<configuration>
		    <tasks>
			<if>
			    <equals arg1="${generate.hbm.files}" arg2="true"/>
			    <then>
				    [do stuff]
			    </then>
			</if>
		    </tasks>
		</configuration>
		<goals>
		    <goal>run</goal>
		</goals>
	</execution>

so that we can call mvn clean package -Dgenerate.hbm.files=true or mvn clean
package -Dgenerate.hbm.files=false as necessary


Kristof Vanbecelaere wrote:
> 
> Maybe I need to rephrase this a bit. Your line of reasoning is absolutely
> correct from a process point of view (like a CI build). But rigorously
> applying this principle across the board denies developers the comfort of
> selectively running subsets of tests. Developer productivity should count
> for something as well.
> 
> 
> Kristof Vanbecelaere wrote:
>> 
>> I disagree. Have you ever written a selenium test? This is trial and
>> error. I have not touched any "real" code, only test code. So I know my
>> unit tests succeed. All I want to do is run the integration-test phase
>> without unit tests.
>> 
>> 
>> Stephen Connolly-2 wrote:
>>> 
>>> 2008/11/27 Kristof Vanbecelaere <kr...@gmail.com>
>>> 
>>> Actually, that is the aim.
>>> 
>>> You run all the unit tests to make sure that the code is good enough to
>>> try
>>> and run the integration tests.
>>> 
>>> If your unit tests fail, your code is broken and you know it, so fix
>>> your
>>> code.
>>> 
>>> If your unit tests pass, now lets see if it integrates correctly, hence
>>> run
>>> the integration tests.
>>> 
>>> If the integration tests pass, we can publish the project (i.e. install
>>> or
>>> deploy to maven repo)
>>> 
>>> This is what the lifecycle is all about... a well defined sequence of
>>> phases, all the previous phases must complete successfully before the
>>> next
>>> phase starts.
>>> 
>>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/maven-surefire-plugin-configuration-for-unit-integration-tests-tp20724622p23128862.html
Sent from the Maven - Users mailing list archive at Nabble.com.


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


Re: maven-surefire-plugin configuration for unit/integration tests

Posted by Kristof Vanbecelaere <kr...@gmail.com>.
Maybe I need to rephrase this a bit. Your line of reasoning is absolutely
correct from a process point of view (like a CI build). But rigorously
applying this principle across the board denies developers the comfort of
selectively running subsets of tests. Developer productivity should count
for something as well.


Kristof Vanbecelaere wrote:
> 
> I disagree. Have you ever written a selenium test? This is trial and
> error. I have not touched any "real" code, only test code. So I know my
> unit tests succeed. All I want to do is run the integration-test phase
> without unit tests.
> 
> 
> Stephen Connolly-2 wrote:
>> 
>> 2008/11/27 Kristof Vanbecelaere <kr...@gmail.com>
>> 
>> Actually, that is the aim.
>> 
>> You run all the unit tests to make sure that the code is good enough to
>> try
>> and run the integration tests.
>> 
>> If your unit tests fail, your code is broken and you know it, so fix your
>> code.
>> 
>> If your unit tests pass, now lets see if it integrates correctly, hence
>> run
>> the integration tests.
>> 
>> If the integration tests pass, we can publish the project (i.e. install
>> or
>> deploy to maven repo)
>> 
>> This is what the lifecycle is all about... a well defined sequence of
>> phases, all the previous phases must complete successfully before the
>> next
>> phase starts.
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/maven-surefire-plugin-configuration-for-unit-integration-tests-tp20724622p20730746.html
Sent from the Maven - Users mailing list archive at Nabble.com.


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


RE: maven-surefire-plugin configuration for unit/integration tests

Posted by "Bracewell, Robert" <rb...@qualcomm.com>.
It is possible to just run unit tests or integration tests from a module but it gets messy and over complicated.
For example I have projects that separate tests by placing all unit tests in a directory called unit and all integration tests in a directory called it.
With such a separation it makes it easier to configure the compile plug-in to exclude tests at certain phases. Likewise the surefire plug-in needs to be configured accordingly with excludes and includes. Then using a profile you can invoke the integration tests which will only run integration tests.

This all works fine until you need to generate a site that contains both surefire reports for unit test runs and integration test runs. It's not straightforward as the underlying surefire report plug-in is not as flexible.

I'm just waiting for when the next major release of Maven is made as the issue of test separation I believe is addressed

--
Robert

-----Original Message-----
From: Kristof Vanbecelaere [mailto:kristof.vanbecelaere@gmail.com] 
Sent: Friday, November 28, 2008 12:03 AM
To: users@maven.apache.org
Subject: Re: maven-surefire-plugin configuration for unit/integration tests


I disagree. Have you ever written a selenium test? This is trial and error. I
have not touched any "real" code, only test code. So I know my unit tests
succeed. All I want to do is run the integration-test phase without unit
tests.


Stephen Connolly-2 wrote:
> 
> 2008/11/27 Kristof Vanbecelaere <kr...@gmail.com>
> 
> Actually, that is the aim.
> 
> You run all the unit tests to make sure that the code is good enough to
> try
> and run the integration tests.
> 
> If your unit tests fail, your code is broken and you know it, so fix your
> code.
> 
> If your unit tests pass, now lets see if it integrates correctly, hence
> run
> the integration tests.
> 
> If the integration tests pass, we can publish the project (i.e. install or
> deploy to maven repo)
> 
> This is what the lifecycle is all about... a well defined sequence of
> phases, all the previous phases must complete successfully before the next
> phase starts.
> 
> 

-- 
View this message in context: http://www.nabble.com/maven-surefire-plugin-configuration-for-unit-integration-tests-tp20724622p20730286.html
Sent from the Maven - Users mailing list archive at Nabble.com.


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


Re: maven-surefire-plugin configuration for unit/integration tests

Posted by Kristof Vanbecelaere <kr...@gmail.com>.
I disagree. Have you ever written a selenium test? This is trial and error. I
have not touched any "real" code, only test code. So I know my unit tests
succeed. All I want to do is run the integration-test phase without unit
tests.


Stephen Connolly-2 wrote:
> 
> 2008/11/27 Kristof Vanbecelaere <kr...@gmail.com>
> 
> Actually, that is the aim.
> 
> You run all the unit tests to make sure that the code is good enough to
> try
> and run the integration tests.
> 
> If your unit tests fail, your code is broken and you know it, so fix your
> code.
> 
> If your unit tests pass, now lets see if it integrates correctly, hence
> run
> the integration tests.
> 
> If the integration tests pass, we can publish the project (i.e. install or
> deploy to maven repo)
> 
> This is what the lifecycle is all about... a well defined sequence of
> phases, all the previous phases must complete successfully before the next
> phase starts.
> 
> 

-- 
View this message in context: http://www.nabble.com/maven-surefire-plugin-configuration-for-unit-integration-tests-tp20724622p20730286.html
Sent from the Maven - Users mailing list archive at Nabble.com.


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


Re: maven-surefire-plugin configuration for unit/integration tests

Posted by Kristof Vanbecelaere <kr...@gmail.com>.
No, that is the point. Hand-running the integration-test goal runs unit tests
as well.


John Stoneham wrote:
> 
> 
> Hand-running the integration-test goal will also work well, if there's 
> just one. Or a profile would work nicely.
> 
> - John
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/maven-surefire-plugin-configuration-for-unit-integration-tests-tp20724622p20730300.html
Sent from the Maven - Users mailing list archive at Nabble.com.


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


Re: maven-surefire-plugin configuration for unit/integration tests

Posted by John Stoneham <ly...@lyrically.net>.
> And if you really just want to run integration tests pull these out
> into their own module which contains no unit tests.

Hand-running the integration-test goal will also work well, if there's 
just one. Or a profile would work nicely.

- John

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


Re: maven-surefire-plugin configuration for unit/integration tests

Posted by Barrie Treloar <ba...@gmail.com>.
>> Unfortunately, I failed to make it work. When running mvn integration-test
>> all unit tests get to run before running the integration tests, which is
>> not
>> really the aim. The idea really is to be able to either run unit tests or
>> integration tests but not both at the same time. Any ideas why this fails?
>>
>
> Actually, that is the aim.
>
> You run all the unit tests to make sure that the code is good enough to try
> and run the integration tests.
>
> If your unit tests fail, your code is broken and you know it, so fix your
> code.
>
> If your unit tests pass, now lets see if it integrates correctly, hence run
> the integration tests.
>
> If the integration tests pass, we can publish the project (i.e. install or
> deploy to maven repo)
>
> This is what the lifecycle is all about... a well defined sequence of
> phases, all the previous phases must complete successfully before the next
> phase starts.

And if you really just want to run integration tests pull these out
into their own module which contains no unit tests.

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


Re: maven-surefire-plugin configuration for unit/integration tests

Posted by Stephen Connolly <st...@gmail.com>.
2008/11/27 Kristof Vanbecelaere <kr...@gmail.com>

>
> Hello,
>
> I found this interesting blog:
>
> http://weblogs.java.net/blog/johnsmart/archive/2008/06/unit_tests_are.html
>
> Unfortunately, I failed to make it work. When running mvn integration-test
> all unit tests get to run before running the integration tests, which is
> not
> really the aim. The idea really is to be able to either run unit tests or
> integration tests but not both at the same time. Any ideas why this fails?
>

Actually, that is the aim.

You run all the unit tests to make sure that the code is good enough to try
and run the integration tests.

If your unit tests fail, your code is broken and you know it, so fix your
code.

If your unit tests pass, now lets see if it integrates correctly, hence run
the integration tests.

If the integration tests pass, we can publish the project (i.e. install or
deploy to maven repo)

This is what the lifecycle is all about... a well defined sequence of
phases, all the previous phases must complete successfully before the next
phase starts.

-Stephen

>
> I guess the only real way (still) to split off integration tests is to have
> a separate module wherein to place these integration tests and put no unit
> tests in said module. Or is there?
>
> Thanks.
> --
> View this message in context:
> http://www.nabble.com/maven-surefire-plugin-configuration-for-unit-integration-tests-tp20724622p20724622.html
> Sent from the Maven - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>