You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by Jim Bethancourt <ji...@gmail.com> on 2007/03/21 20:17:57 UTC

Unit Test inheritance in a multi-pom project?

Hi all,
I'm working on a multi-pom project and would like to inherit from classes in
the test hierarchy across modules in the project, and I'm listing each
module as a dependency in the parent pom as well.  I've done several
experiments to see if this is possible and have had no success.  What would
be the appropriate way to enable inheritance of classes in the test
hierarchy across modules during the test-compile phase of a multi-pom
project?  Is such a feature available right now for Maven 2, or should I
submit a JIRA request?

Thanks,
Jim

RE: Unit Test inheritance in a multi-pom project?

Posted by "Brian E. Fox" <br...@reply.infinity.nu>.
I believe that this has been fixed by
http://jira.codehaus.org/browse/MNG-2877 in Maven 2.0.6.

-----Original Message-----
From: Jim Bethancourt [mailto:jimbethancourt@gmail.com] 
Sent: Saturday, March 24, 2007 5:02 PM
To: Maven Users List; Maven Developers List
Subject: Re: Unit Test inheritance in a multi-pom project?

Hi GreJ,
I believe that is correct.  A mvn install must be done in order to make
the
test jars available on the classpath to compile against for the
inherited
tests.  I agree that it is unfortunate that an install must be done in
order
to run the tests.

Maven developers,
Should I submit a feature request on Jira?  It would be something to the
effect like "Test jars / test-classes source directories need to be
available on the classpath within the reactor during the test-compile
phase
so users don't need to perform an install in order to compile against
code
in other test-jars / test-classes source directories"  How's that sound?

It would also be handy to have transitive dependency management of the
test-jars, but that should probably be for another feature request.

Thanks,
Jim

On 3/23/07, GreJ <gr...@gmail.com> wrote:
>
>
> Hi,
>
> Thanks for your answer,
>
> I do several tests, and in fact it doesn't work without install. The
test
> jar really needed to be installed in the local repository(?).
>
> This is my project layout
>
> -Root
> +sslServer
> +client
>
> client must use the test-jar generated by the sslServer module. So
here is
> the dependencies of the client module :
> <dependencies>
>                 <dependency>
>                         <artifactId>sslServer</artifactId>
>                         <groupId>org.inpres</groupId>
>                         <version>1.0</version>
>                 </dependency>
>                 <dependency>
>                         <groupId>org.inpres</groupId>
>                         <artifactId>aw-sslServer</artifactId>
>                         <version>1.0</version>
>                         <type>test-jar</type>
>                 </dependency>
>         </dependencies>
>
> There is no problem to resolvethe dependency to the
org.inpres:sslServer.
> By
> compile, or package, there is no problem. But the test-jar ist not
found
> while no install is called.
> It's pitty to need to run the install and so to install all the jars
if we
> just need to compile the tests :(
> Is there a praticular reason that the sslServer dependency is found by
> compile or packaging, but not the tests?
> My aim is just to compile or run the tests, where the tests of the
client
> need classes from the sslServer...
> --
> View this message in context:
>
http://www.nabble.com/Unit-Test-inheritance-in-a-multi-pom-project--tf34
42738s177.html#a9644535
> 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: Unit Test inheritance in a multi-pom project?

Posted by Jim Bethancourt <ji...@gmail.com>.
Hi GreJ,
I believe that is correct.  A mvn install must be done in order to make the
test jars available on the classpath to compile against for the inherited
tests.  I agree that it is unfortunate that an install must be done in order
to run the tests.

Maven developers,
Should I submit a feature request on Jira?  It would be something to the
effect like "Test jars / test-classes source directories need to be
available on the classpath within the reactor during the test-compile phase
so users don't need to perform an install in order to compile against code
in other test-jars / test-classes source directories"  How's that sound?

It would also be handy to have transitive dependency management of the
test-jars, but that should probably be for another feature request.

Thanks,
Jim

On 3/23/07, GreJ <gr...@gmail.com> wrote:
>
>
> Hi,
>
> Thanks for your answer,
>
> I do several tests, and in fact it doesn't work without install. The test
> jar really needed to be installed in the local repository(?).
>
> This is my project layout
>
> -Root
> +sslServer
> +client
>
> client must use the test-jar generated by the sslServer module. So here is
> the dependencies of the client module :
> <dependencies>
>                 <dependency>
>                         <artifactId>sslServer</artifactId>
>                         <groupId>org.inpres</groupId>
>                         <version>1.0</version>
>                 </dependency>
>                 <dependency>
>                         <groupId>org.inpres</groupId>
>                         <artifactId>aw-sslServer</artifactId>
>                         <version>1.0</version>
>                         <type>test-jar</type>
>                 </dependency>
>         </dependencies>
>
> There is no problem to resolvethe dependency to the org.inpres:sslServer.
> By
> compile, or package, there is no problem. But the test-jar ist not found
> while no install is called.
> It's pitty to need to run the install and so to install all the jars if we
> just need to compile the tests :(
> Is there a praticular reason that the sslServer dependency is found by
> compile or packaging, but not the tests?
> My aim is just to compile or run the tests, where the tests of the client
> need classes from the sslServer...
> --
> View this message in context:
> http://www.nabble.com/Unit-Test-inheritance-in-a-multi-pom-project--tf3442738s177.html#a9644535
> 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: Unit Test inheritance in a multi-pom project?

Posted by Jim Bethancourt <ji...@gmail.com>.
Hi GreJ,
I believe that is correct.  A mvn install must be done in order to make the
test jars available on the classpath to compile against for the inherited
tests.  I agree that it is unfortunate that an install must be done in order
to run the tests.

Maven developers,
Should I submit a feature request on Jira?  It would be something to the
effect like "Test jars / test-classes source directories need to be
available on the classpath within the reactor during the test-compile phase
so users don't need to perform an install in order to compile against code
in other test-jars / test-classes source directories"  How's that sound?

It would also be handy to have transitive dependency management of the
test-jars, but that should probably be for another feature request.

Thanks,
Jim

On 3/23/07, GreJ <gr...@gmail.com> wrote:
>
>
> Hi,
>
> Thanks for your answer,
>
> I do several tests, and in fact it doesn't work without install. The test
> jar really needed to be installed in the local repository(?).
>
> This is my project layout
>
> -Root
> +sslServer
> +client
>
> client must use the test-jar generated by the sslServer module. So here is
> the dependencies of the client module :
> <dependencies>
>                 <dependency>
>                         <artifactId>sslServer</artifactId>
>                         <groupId>org.inpres</groupId>
>                         <version>1.0</version>
>                 </dependency>
>                 <dependency>
>                         <groupId>org.inpres</groupId>
>                         <artifactId>aw-sslServer</artifactId>
>                         <version>1.0</version>
>                         <type>test-jar</type>
>                 </dependency>
>         </dependencies>
>
> There is no problem to resolvethe dependency to the org.inpres:sslServer.
> By
> compile, or package, there is no problem. But the test-jar ist not found
> while no install is called.
> It's pitty to need to run the install and so to install all the jars if we
> just need to compile the tests :(
> Is there a praticular reason that the sslServer dependency is found by
> compile or packaging, but not the tests?
> My aim is just to compile or run the tests, where the tests of the client
> need classes from the sslServer...
> --
> View this message in context:
> http://www.nabble.com/Unit-Test-inheritance-in-a-multi-pom-project--tf3442738s177.html#a9644535
> 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: Unit Test inheritance in a multi-pom project?

Posted by GreJ <gr...@gmail.com>.
Hi,

Thanks for your answer,

I do several tests, and in fact it doesn't work without install. The test
jar really needed to be installed in the local repository(?). 

This is my project layout 

-Root
 +sslServer
 +client

client must use the test-jar generated by the sslServer module. So here is
the dependencies of the client module :
<dependencies>
		<dependency>
			<artifactId>sslServer</artifactId>
			<groupId>org.inpres</groupId>
			<version>1.0</version>
		</dependency>
		<dependency>
			<groupId>org.inpres</groupId>
			<artifactId>aw-sslServer</artifactId>
			<version>1.0</version>
			<type>test-jar</type>
		</dependency>
	</dependencies>

There is no problem to resolvethe dependency to the org.inpres:sslServer. By
compile, or package, there is no problem. But the test-jar ist not found
while no install is called.
It's pitty to need to run the install and so to install all the jars if we
just need to compile the tests :(
Is there a praticular reason that the sslServer dependency is found by
compile or packaging, but not the tests?
My aim is just to compile or run the tests, where the tests of the client
need classes from the sslServer... 
-- 
View this message in context: http://www.nabble.com/Unit-Test-inheritance-in-a-multi-pom-project--tf3442738s177.html#a9644535
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: Unit Test inheritance in a multi-pom project?

Posted by Jim Bethancourt <ji...@gmail.com>.
Hi GreJ,
You must do an install in order for the test-jar to be available, otherwise
it won't be installed and can't be referenced as a jar by the dependent
project.  You will also need to list the dependency as a normal dependency
and a test jar in order to successfully do a mvn compile and mvn install.

For example, if I have a module called "common" with both code and tests I'm
referencing in the current pom/proejct, I would need to have the following
in my child pom:

    <dependency>
      <groupId>org.myapp</groupId>
      <artifactId>common</artifactId>
    </dependency>
    <dependency>
      <groupId>org.myapp</groupId>
      <artifactId>common</artifactId>
      <version>${appVersion}</version>
      <type>test-jar</type>
      <scope>test</scope>
    </dependency>

I've also noticed that while Maven manages transitive dependencies for your
application modules, it is not the case for the test jars, so if you have
multiple test jars you're using, you'll need to list them all, even if they
are also dependencies of a module you've already listed.

This is what I've had to do to get it to work, anyway.  I haven't tried the
package command yet in this situation, so I can't speak for what happens
there.

Hope this helps,
Jim


On 3/23/07, GreJ <gr...@gmail.com> wrote:
>
>
> Hi,
>
> I have the same problem and followed exactly the maven2 help.
> But it seems that Maven2 can't find the test-jar without the install. So
> the
> dependency ist not resolved.
> It works only with an install, and not with the 'package' command.
>
> Is it a bug ?
> [Sorry for the bad english, i need more practice ;) ]
>
>
>
> Jim Bethancourt wrote:
> >
> > Yup!  That did the trick.
> >
> > Thanks Jason!
> > Jim
> >
> > On 3/21/07, Jim Bethancourt <ji...@gmail.com> wrote:
> >>
> >> Cool!  That looks exactly like what I need.  I'll give it a go. ;-)
> >>
> >> Thanks,
> >> Jim
> >>
> >> On 3/21/07, Jason van Zyl < jason@maven.org> wrote:
> >> >
> >> >
> >> > On 21 Mar 07, at 3:17 PM 21 Mar 07, Jim Bethancourt wrote:
> >> >
> >> > > Hi all,
> >> > > I'm working on a multi-pom project and would like to inherit from
> >> > > classes in
> >> > > the test hierarchy across modules in the project, and I'm listing
> >> each
> >> > > module as a dependency in the parent pom as well.  I've done
> several
> >> > > experiments to see if this is possible and have had no success.
> >> > > What would
> >> > > be the appropriate way to enable inheritance of classes in the test
> >> > > hierarchy across modules during the test-compile phase of a
> multi-pom
> >> > > project?  Is such a feature available right now for Maven 2, or
> >> > > should I
> >> > > submit a JIRA request?
> >> >
> >> > I think this is what you're looking for:
> >> >
> >> > http://maven.apache.org/guides/mini/guide-attached-tests.html
> >> >
> >> > >
> >> > > Thanks,
> >> > > Jim
> >> >
> >> >
> >> > ---------------------------------------------------------------------
> >> > To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> >> > For additional commands, e-mail: dev-help@maven.apache.org
> >> >
> >> >
> >>
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/Unit-Test-inheritance-in-a-multi-pom-project--tf3442738s177.html#a9642658
> 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: Unit Test inheritance in a multi-pom project?

Posted by GreJ <gr...@gmail.com>.
Hi, 

I have the same problem and followed exactly the maven2 help. 
But it seems that Maven2 can't find the test-jar without the install. So the
dependency ist not resolved. 
It works only with an install, and not with the 'package' command.

Is it a bug ?
[Sorry for the bad english, i need more practice ;) ]



Jim Bethancourt wrote:
> 
> Yup!  That did the trick.
> 
> Thanks Jason!
> Jim
> 
> On 3/21/07, Jim Bethancourt <ji...@gmail.com> wrote:
>>
>> Cool!  That looks exactly like what I need.  I'll give it a go. ;-)
>>
>> Thanks,
>> Jim
>>
>> On 3/21/07, Jason van Zyl < jason@maven.org> wrote:
>> >
>> >
>> > On 21 Mar 07, at 3:17 PM 21 Mar 07, Jim Bethancourt wrote:
>> >
>> > > Hi all,
>> > > I'm working on a multi-pom project and would like to inherit from
>> > > classes in
>> > > the test hierarchy across modules in the project, and I'm listing
>> each
>> > > module as a dependency in the parent pom as well.  I've done several
>> > > experiments to see if this is possible and have had no success.
>> > > What would
>> > > be the appropriate way to enable inheritance of classes in the test
>> > > hierarchy across modules during the test-compile phase of a multi-pom
>> > > project?  Is such a feature available right now for Maven 2, or
>> > > should I
>> > > submit a JIRA request?
>> >
>> > I think this is what you're looking for:
>> >
>> > http://maven.apache.org/guides/mini/guide-attached-tests.html
>> >
>> > >
>> > > Thanks,
>> > > Jim
>> >
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
>> > For additional commands, e-mail: dev-help@maven.apache.org
>> >
>> >
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/Unit-Test-inheritance-in-a-multi-pom-project--tf3442738s177.html#a9642658
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: Unit Test inheritance in a multi-pom project?

Posted by Jim Bethancourt <ji...@gmail.com>.
Yup!  That did the trick.

Thanks Jason!
Jim

On 3/21/07, Jim Bethancourt <ji...@gmail.com> wrote:
>
> Cool!  That looks exactly like what I need.  I'll give it a go. ;-)
>
> Thanks,
> Jim
>
> On 3/21/07, Jason van Zyl < jason@maven.org> wrote:
> >
> >
> > On 21 Mar 07, at 3:17 PM 21 Mar 07, Jim Bethancourt wrote:
> >
> > > Hi all,
> > > I'm working on a multi-pom project and would like to inherit from
> > > classes in
> > > the test hierarchy across modules in the project, and I'm listing each
> > > module as a dependency in the parent pom as well.  I've done several
> > > experiments to see if this is possible and have had no success.
> > > What would
> > > be the appropriate way to enable inheritance of classes in the test
> > > hierarchy across modules during the test-compile phase of a multi-pom
> > > project?  Is such a feature available right now for Maven 2, or
> > > should I
> > > submit a JIRA request?
> >
> > I think this is what you're looking for:
> >
> > http://maven.apache.org/guides/mini/guide-attached-tests.html
> >
> > >
> > > Thanks,
> > > Jim
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> > For additional commands, e-mail: dev-help@maven.apache.org
> >
> >
>

Re: Unit Test inheritance in a multi-pom project?

Posted by Jim Bethancourt <ji...@gmail.com>.
Yup!  That did the trick.

Thanks Jason!
Jim

On 3/21/07, Jim Bethancourt <ji...@gmail.com> wrote:
>
> Cool!  That looks exactly like what I need.  I'll give it a go. ;-)
>
> Thanks,
> Jim
>
> On 3/21/07, Jason van Zyl < jason@maven.org> wrote:
> >
> >
> > On 21 Mar 07, at 3:17 PM 21 Mar 07, Jim Bethancourt wrote:
> >
> > > Hi all,
> > > I'm working on a multi-pom project and would like to inherit from
> > > classes in
> > > the test hierarchy across modules in the project, and I'm listing each
> > > module as a dependency in the parent pom as well.  I've done several
> > > experiments to see if this is possible and have had no success.
> > > What would
> > > be the appropriate way to enable inheritance of classes in the test
> > > hierarchy across modules during the test-compile phase of a multi-pom
> > > project?  Is such a feature available right now for Maven 2, or
> > > should I
> > > submit a JIRA request?
> >
> > I think this is what you're looking for:
> >
> > http://maven.apache.org/guides/mini/guide-attached-tests.html
> >
> > >
> > > Thanks,
> > > Jim
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> > For additional commands, e-mail: dev-help@maven.apache.org
> >
> >
>

Re: Unit Test inheritance in a multi-pom project?

Posted by Jim Bethancourt <ji...@gmail.com>.
Cool!  That looks exactly like what I need.  I'll give it a go. ;-)

Thanks,
Jim

On 3/21/07, Jason van Zyl <ja...@maven.org> wrote:
>
>
> On 21 Mar 07, at 3:17 PM 21 Mar 07, Jim Bethancourt wrote:
>
> > Hi all,
> > I'm working on a multi-pom project and would like to inherit from
> > classes in
> > the test hierarchy across modules in the project, and I'm listing each
> > module as a dependency in the parent pom as well.  I've done several
> > experiments to see if this is possible and have had no success.
> > What would
> > be the appropriate way to enable inheritance of classes in the test
> > hierarchy across modules during the test-compile phase of a multi-pom
> > project?  Is such a feature available right now for Maven 2, or
> > should I
> > submit a JIRA request?
>
> I think this is what you're looking for:
>
> http://maven.apache.org/guides/mini/guide-attached-tests.html
>
> >
> > Thanks,
> > Jim
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>
>

Re: Unit Test inheritance in a multi-pom project?

Posted by Jason van Zyl <ja...@maven.org>.
On 21 Mar 07, at 3:17 PM 21 Mar 07, Jim Bethancourt wrote:

> Hi all,
> I'm working on a multi-pom project and would like to inherit from  
> classes in
> the test hierarchy across modules in the project, and I'm listing each
> module as a dependency in the parent pom as well.  I've done several
> experiments to see if this is possible and have had no success.   
> What would
> be the appropriate way to enable inheritance of classes in the test
> hierarchy across modules during the test-compile phase of a multi-pom
> project?  Is such a feature available right now for Maven 2, or  
> should I
> submit a JIRA request?

I think this is what you're looking for:

http://maven.apache.org/guides/mini/guide-attached-tests.html

>
> Thanks,
> Jim


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