You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by CheapLisa <li...@purpleblade.net> on 2008/12/09 22:35:18 UTC

How to run JUnit tests in sub-modules without surefire reference?

I want to run JUnit tests in every module and sub-module (some 5 deep),
but I do not want to put a reference to the surefire plugin 
in every pom.xml  in every module and sub-module (some 5 deep).

How do I make this work?

--- More Info

I have a top level pom for all modules and use the <parent> tag in every
module and sub-module
(some 5 deep).  

In the top level pom, I have a reference to the surefire plugin,
but this strategy does not seem
to work.

This is what I have:

	dir structure
		<project_root>/pom.xml		<= this is my parent pom
	
	<project_root>/<module>/<sub_module>/../pom.xml
	In this pom.xml (and in every sub-module pom - some 5 deep) I have:
	
		<!-- reference to parent-pom in every sub-module - some 5 deep -->
	    <parent>
			<groupId>com.acme</groupId>
			<artifactId>my-parent-pom</artifactId>
			<version>1.0</version>
		</parent>
		
		...
		and later in the parent pome mentioned above I have the following:
		
		<plugin>
			<groupId>org.apache.maven.plugins</groupId>
			<artifactId>maven-surefire-plugin</artifactId>
			<configuration>
				<haltOnFailure>true</haltOnFailure>
				<skip>true</skip>
				<useFile>false</useFile>
			</configuration>
		</plugin>
		
		I do not want this plugin section in every pom.xml in every sub-module
(some 5 deep)
		How do I do this to make it go?
-- 
View this message in context: http://www.nabble.com/How-to-run-JUnit-tests-in-sub-modules-without-surefire-reference--tp20924140p20924140.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: How to run JUnit tests in sub-modules without surefire reference?

Posted by CheapLisa <li...@purpleblade.net>.
I did this and only see a reference to maven-surefire-reports in the
reporting section but not elsewhere.

My objective is to clean up my pom's and not repeat what is not really
needed.  It seams like having a reference to surefire in a build section in
every module pom is tedious to include and maintain.


thanks

L



Wayne Fay wrote:
> 
>> thanks, so there is absolutely no way to rid every single pom.xml with
>> some
>> reference to junit for example?
> 
> I guess I still don't know what your objective is.
> 
> Surefire is in the super pom (in Maven's jars), so *all* poms will
> have a reference to it, directly or inherited. If you make a new
> project with a nearly empty pom and try "mvn help:effective-pom",
> you'll see Surefire in it.
> 
> As for JUnit, Surefire knows how to run JUnit tests, but it doesn't
> explicitly depend on JUnit, so you'll need to include a reference to
> it at least in the top parent's pom files and it should be inherited
> by the children. So no, you don't need to include junit in "every
> single pom.xml".
> 
> I think you need to make some sample projects and play around with
> help:effective-pom to see how it all works, then come back with
> specific questions if you have any.
> 
> Wayne
> 
> ---------------------------------------------------------------------
> 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/How-to-run-JUnit-tests-in-sub-modules-without-surefire-reference--tp20924140p20943614.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: How to run JUnit tests in sub-modules without surefire reference?

Posted by Wayne Fay <wa...@gmail.com>.
> thanks, so there is absolutely no way to rid every single pom.xml with some
> reference to junit for example?

I guess I still don't know what your objective is.

Surefire is in the super pom (in Maven's jars), so *all* poms will
have a reference to it, directly or inherited. If you make a new
project with a nearly empty pom and try "mvn help:effective-pom",
you'll see Surefire in it.

As for JUnit, Surefire knows how to run JUnit tests, but it doesn't
explicitly depend on JUnit, so you'll need to include a reference to
it at least in the top parent's pom files and it should be inherited
by the children. So no, you don't need to include junit in "every
single pom.xml".

I think you need to make some sample projects and play around with
help:effective-pom to see how it all works, then come back with
specific questions if you have any.

Wayne

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


Re: How to run JUnit tests in sub-modules without surefire reference?

Posted by Stephen Connolly <st...@gmail.com>.
dependencyManagement is used to specify what version to use *if* the  
artifact is specified as a dependency

dependencies specifies which artifacts are dependencies

Sent from my iPod

On 10 Dec 2008, at 20:53, CheapLisa <li...@purpleblade.net> wrote:

>
> thanks, what is the difference between dependency and  
> dependencyManagement?
>
> thanks
>
> L
>
>
>
> Stephen Connolly-2 wrote:
>>
>> You could add junit as a test <dependency> to your parent pom...  
>> that is a
>> dependency not dependencyManagement....
>>
>> Might cause more problems than it fixes though!
>>
>> -Stephen
>>
>> 2008/12/10 CheapLisa <li...@purpleblade.net>
>>
>>>
>>> thanks, so there is absolutely no way to rid every single pom.xml  
>>> with
>>> some
>>> reference to junit for example?
>>>
>>> Lisa
>>>
>>>
>>>
>>> Wayne Fay wrote:
>>>>
>>>>>               I do not want this plugin section in every pom.xml  
>>>>> in
>>>>> every sub-module
>>>>> (some 5 deep)
>>>>>               How do I do this to make it go?
>>>>
>>>> Generally, you should configure plugins like this in the
>>>> <pluginManagement> section in the top parent, and then when you
>>>> declare the plugin in each child, it will inherit the configuration
>>>> from the parent.
>>>>
>>>> So the parent has the "big configuration" section in pluginMgmt,  
>>>> and
>>>> the children just have:
>>>> <plugin>
>>>>  <groupId>org.apache.maven.plugins</groupId>
>>>>  <artifactId>maven-surefire-plugin</artifactId>
>>>> </plugin>
>>>>
>>>> Of course, surefire is already declared in the super pom, so you
>>>> shouldn't even need to include that in the children. Check "mvn
>>>> help:effective-pom" in a child once you've added that  
>>>> configuration to
>>>> the top parent -- it should show up.
>>>>
>>>> Wayne
>>>>
>>>> --- 
>>>> ------------------------------------------------------------------
>>>> 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/How-to-run-JUnit-tests-in-sub-modules-without-surefire-reference--tp20924140p20929409.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
>>>
>>>
>>
>>
>
> -- 
> View this message in context: http://www.nabble.com/How-to-run-JUnit-tests-in-sub-modules-without-surefire-reference--tp20924140p20943650.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: How to run JUnit tests in sub-modules without surefire reference?

Posted by Wayne Fay <wa...@gmail.com>.
> thanks, what is the difference between dependency and dependencyManagement?

The Maven website, various free PDFs (Better Builds with Maven etc),
and Google can all answer this question for you:
http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html

Wayne

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


Re: How to run JUnit tests in sub-modules without surefire reference?

Posted by CheapLisa <li...@purpleblade.net>.
thanks, what is the difference between dependency and dependencyManagement?

thanks

L



Stephen Connolly-2 wrote:
> 
> You could add junit as a test <dependency> to your parent pom... that is a
> dependency not dependencyManagement....
> 
> Might cause more problems than it fixes though!
> 
> -Stephen
> 
> 2008/12/10 CheapLisa <li...@purpleblade.net>
> 
>>
>> thanks, so there is absolutely no way to rid every single pom.xml with
>> some
>> reference to junit for example?
>>
>> Lisa
>>
>>
>>
>> Wayne Fay wrote:
>> >
>> >>                I do not want this plugin section in every pom.xml in
>> >> every sub-module
>> >> (some 5 deep)
>> >>                How do I do this to make it go?
>> >
>> > Generally, you should configure plugins like this in the
>> > <pluginManagement> section in the top parent, and then when you
>> > declare the plugin in each child, it will inherit the configuration
>> > from the parent.
>> >
>> > So the parent has the "big configuration" section in pluginMgmt, and
>> > the children just have:
>> > <plugin>
>> >   <groupId>org.apache.maven.plugins</groupId>
>> >   <artifactId>maven-surefire-plugin</artifactId>
>> > </plugin>
>> >
>> > Of course, surefire is already declared in the super pom, so you
>> > shouldn't even need to include that in the children. Check "mvn
>> > help:effective-pom" in a child once you've added that configuration to
>> > the top parent -- it should show up.
>> >
>> > Wayne
>> >
>> > ---------------------------------------------------------------------
>> > 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/How-to-run-JUnit-tests-in-sub-modules-without-surefire-reference--tp20924140p20929409.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
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-run-JUnit-tests-in-sub-modules-without-surefire-reference--tp20924140p20943650.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: How to run JUnit tests in sub-modules without surefire reference?

Posted by Stephen Connolly <st...@gmail.com>.
You could add junit as a test <dependency> to your parent pom... that is a
dependency not dependencyManagement....

Might cause more problems than it fixes though!

-Stephen

2008/12/10 CheapLisa <li...@purpleblade.net>

>
> thanks, so there is absolutely no way to rid every single pom.xml with some
> reference to junit for example?
>
> Lisa
>
>
>
> Wayne Fay wrote:
> >
> >>                I do not want this plugin section in every pom.xml in
> >> every sub-module
> >> (some 5 deep)
> >>                How do I do this to make it go?
> >
> > Generally, you should configure plugins like this in the
> > <pluginManagement> section in the top parent, and then when you
> > declare the plugin in each child, it will inherit the configuration
> > from the parent.
> >
> > So the parent has the "big configuration" section in pluginMgmt, and
> > the children just have:
> > <plugin>
> >   <groupId>org.apache.maven.plugins</groupId>
> >   <artifactId>maven-surefire-plugin</artifactId>
> > </plugin>
> >
> > Of course, surefire is already declared in the super pom, so you
> > shouldn't even need to include that in the children. Check "mvn
> > help:effective-pom" in a child once you've added that configuration to
> > the top parent -- it should show up.
> >
> > Wayne
> >
> > ---------------------------------------------------------------------
> > 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/How-to-run-JUnit-tests-in-sub-modules-without-surefire-reference--tp20924140p20929409.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: How to run JUnit tests in sub-modules without surefire reference?

Posted by CheapLisa <li...@purpleblade.net>.
thanks, so there is absolutely no way to rid every single pom.xml with some
reference to junit for example?

Lisa



Wayne Fay wrote:
> 
>>                I do not want this plugin section in every pom.xml in
>> every sub-module
>> (some 5 deep)
>>                How do I do this to make it go?
> 
> Generally, you should configure plugins like this in the
> <pluginManagement> section in the top parent, and then when you
> declare the plugin in each child, it will inherit the configuration
> from the parent.
> 
> So the parent has the "big configuration" section in pluginMgmt, and
> the children just have:
> <plugin>
>   <groupId>org.apache.maven.plugins</groupId>
>   <artifactId>maven-surefire-plugin</artifactId>
> </plugin>
> 
> Of course, surefire is already declared in the super pom, so you
> shouldn't even need to include that in the children. Check "mvn
> help:effective-pom" in a child once you've added that configuration to
> the top parent -- it should show up.
> 
> Wayne
> 
> ---------------------------------------------------------------------
> 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/How-to-run-JUnit-tests-in-sub-modules-without-surefire-reference--tp20924140p20929409.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: How to run JUnit tests in sub-modules without surefire reference?

Posted by Wayne Fay <wa...@gmail.com>.
>                I do not want this plugin section in every pom.xml in every sub-module
> (some 5 deep)
>                How do I do this to make it go?

Generally, you should configure plugins like this in the
<pluginManagement> section in the top parent, and then when you
declare the plugin in each child, it will inherit the configuration
from the parent.

So the parent has the "big configuration" section in pluginMgmt, and
the children just have:
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-surefire-plugin</artifactId>
</plugin>

Of course, surefire is already declared in the super pom, so you
shouldn't even need to include that in the children. Check "mvn
help:effective-pom" in a child once you've added that configuration to
the top parent -- it should show up.

Wayne

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