You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Giovanni Azua <br...@swissonline.ch> on 2009/01/09 20:14:54 UTC

where to place Test support/reusable fixture classes?

Hi,

I have a multi module project and in one of the top nodes of the dependency
tree I would like to place a Test support class i.e.

AbstractHibernateHSQLTestCase extends junit.framework.TestCase

This class provides automatic database shutdown of HSQL in memory based test
cases to prevent the creation of the inconvenient test.lck and test.log
files.

My problem is that I don't know where to place this utility class. Ideally I
would place it in the test branch of module A but then it will not be
inherited by sub-modules that depend on A say B and C. On the other hand if
I place it under the java branch of module A, then A will compile/runtime
depend on JUnit which I want to avoid at all costs.

I remember I had this same problem trying to define reusable test fixtures
classes but in the hurry I ended up duplicating the fixture classes under
each sub-module.

TIA,
Regards,
Giovanni



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


RE: where to place Test support/reusable fixture classes?

Posted by Jeff Jensen <je...@upstairstechnology.com>.
Yes, you are correct.  Then the next question usually is "so which module do
we attach the common test code to?", and it is probably an arbitrary
decision, unless a "common" module already exists that the others use.  So
that has lead to creating the separate one in my experience.


-----Original Message-----
From: Wim Deblauwe [mailto:wim.deblauwe@gmail.com] 
Sent: Sunday, January 11, 2009 7:49 AM
To: Maven Users List
Subject: Re: where to place Test support/reusable fixture classes?

You don't have to create a separate project if you don't want to. You can
export the test classes in a separate jar with the 'test' classifier and
depend on that jar.

regards,

Wim

2009/1/10 Jeff Jensen <je...@upstairstechnology.com>

> I suggest creating a separate project, e.g. "TestFramework", and place
> those
> types of reusable test classes in its src/main/java.  Then, the other
> projects can depend on it for the test scope.
>
>
> -----Original Message-----
> From: Giovanni Azua [mailto:bravegag@swissonline.ch]
> Sent: Friday, January 09, 2009 1:15 PM
> To: 'Maven Users List'
> Subject: where to place Test support/reusable fixture classes?
>
> Hi,
>
> I have a multi module project and in one of the top nodes of the
dependency
> tree I would like to place a Test support class i.e.
>
> AbstractHibernateHSQLTestCase extends junit.framework.TestCase
>
> This class provides automatic database shutdown of HSQL in memory based
> test
> cases to prevent the creation of the inconvenient test.lck and test.log
> files.
>
> My problem is that I don't know where to place this utility class. Ideally
> I
> would place it in the test branch of module A but then it will not be
> inherited by sub-modules that depend on A say B and C. On the other hand
if
> I place it under the java branch of module A, then A will compile/runtime
> depend on JUnit which I want to avoid at all costs.
>
> I remember I had this same problem trying to define reusable test fixtures
> classes but in the hurry I ended up duplicating the fixture classes under
> each sub-module.
>
> TIA,
> Regards,
> Giovanni
>
>
>
> ---------------------------------------------------------------------
> 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
>
>


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


Re: where to place Test support/reusable fixture classes?

Posted by Wim Deblauwe <wi...@gmail.com>.
You don't have to create a separate project if you don't want to. You can
export the test classes in a separate jar with the 'test' classifier and
depend on that jar.

regards,

Wim

2009/1/10 Jeff Jensen <je...@upstairstechnology.com>

> I suggest creating a separate project, e.g. "TestFramework", and place
> those
> types of reusable test classes in its src/main/java.  Then, the other
> projects can depend on it for the test scope.
>
>
> -----Original Message-----
> From: Giovanni Azua [mailto:bravegag@swissonline.ch]
> Sent: Friday, January 09, 2009 1:15 PM
> To: 'Maven Users List'
> Subject: where to place Test support/reusable fixture classes?
>
> Hi,
>
> I have a multi module project and in one of the top nodes of the dependency
> tree I would like to place a Test support class i.e.
>
> AbstractHibernateHSQLTestCase extends junit.framework.TestCase
>
> This class provides automatic database shutdown of HSQL in memory based
> test
> cases to prevent the creation of the inconvenient test.lck and test.log
> files.
>
> My problem is that I don't know where to place this utility class. Ideally
> I
> would place it in the test branch of module A but then it will not be
> inherited by sub-modules that depend on A say B and C. On the other hand if
> I place it under the java branch of module A, then A will compile/runtime
> depend on JUnit which I want to avoid at all costs.
>
> I remember I had this same problem trying to define reusable test fixtures
> classes but in the hurry I ended up duplicating the fixture classes under
> each sub-module.
>
> TIA,
> Regards,
> Giovanni
>
>
>
> ---------------------------------------------------------------------
> 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: where to place Test support/reusable fixture classes?

Posted by Jeff Jensen <je...@upstairstechnology.com>.
I don't think I fully understand your question on scope.  The only scoping I
am aware of, as I mentioned in first reply, is specified in the
<dependency>:

    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.0</version>
      <scope>test</scope>
    </dependency>

http://maven.apache.org/pom.html#Dependencies

Does that do what you are looking for?

Otherwise, sorry, I am not aware of anything for that!  :-(


-----Original Message-----
From: Giovanni Azua [mailto:bravegag@swissonline.ch] 
Sent: Sunday, January 11, 2009 7:26 AM
To: 'Maven Users List'
Subject: RE: where to place Test support/reusable fixture classes?

Excellent! It did not occur to me creating a separate sub module :) is there
any way to mark a sub module "package private" so other modules outside some
scope won't be able to see it?

Thanks a lot Jeff!

Best regards,
Giovanni

> -----Original Message-----
> From: Jeff Jensen [mailto:jeffjensen@upstairstechnology.com]
> Sent: Saturday, January 10, 2009 2:41 AM
> To: 'Maven Users List'
> Subject: RE: where to place Test support/reusable fixture classes?
> 
> I suggest creating a separate project, e.g. "TestFramework", and place
> those
> types of reusable test classes in its src/main/java.  Then, the other
> projects can depend on it for the test scope.
> 
> 
> -----Original Message-----
> From: Giovanni Azua [mailto:bravegag@swissonline.ch]
> Sent: Friday, January 09, 2009 1:15 PM
> To: 'Maven Users List'
> Subject: where to place Test support/reusable fixture classes?
> 
> Hi,
> 
> I have a multi module project and in one of the top nodes of the
> dependency
> tree I would like to place a Test support class i.e.
> 
> AbstractHibernateHSQLTestCase extends junit.framework.TestCase
> 
> This class provides automatic database shutdown of HSQL in memory based
> test
> cases to prevent the creation of the inconvenient test.lck and test.log
> files.
> 
> My problem is that I don't know where to place this utility class. Ideally
> I
> would place it in the test branch of module A but then it will not be
> inherited by sub-modules that depend on A say B and C. On the other hand
> if
> I place it under the java branch of module A, then A will compile/runtime
> depend on JUnit which I want to avoid at all costs.
> 
> I remember I had this same problem trying to define reusable test fixtures
> classes but in the hurry I ended up duplicating the fixture classes under
> each sub-module.
> 
> TIA,
> Regards,
> Giovanni
> 
> 
> 
> ---------------------------------------------------------------------
> 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




---------------------------------------------------------------------
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: where to place Test support/reusable fixture classes?

Posted by Giovanni Azua <br...@swissonline.ch>.
Excellent! It did not occur to me creating a separate sub module :) is there
any way to mark a sub module "package private" so other modules outside some
scope won't be able to see it?

Thanks a lot Jeff!

Best regards,
Giovanni

> -----Original Message-----
> From: Jeff Jensen [mailto:jeffjensen@upstairstechnology.com]
> Sent: Saturday, January 10, 2009 2:41 AM
> To: 'Maven Users List'
> Subject: RE: where to place Test support/reusable fixture classes?
> 
> I suggest creating a separate project, e.g. "TestFramework", and place
> those
> types of reusable test classes in its src/main/java.  Then, the other
> projects can depend on it for the test scope.
> 
> 
> -----Original Message-----
> From: Giovanni Azua [mailto:bravegag@swissonline.ch]
> Sent: Friday, January 09, 2009 1:15 PM
> To: 'Maven Users List'
> Subject: where to place Test support/reusable fixture classes?
> 
> Hi,
> 
> I have a multi module project and in one of the top nodes of the
> dependency
> tree I would like to place a Test support class i.e.
> 
> AbstractHibernateHSQLTestCase extends junit.framework.TestCase
> 
> This class provides automatic database shutdown of HSQL in memory based
> test
> cases to prevent the creation of the inconvenient test.lck and test.log
> files.
> 
> My problem is that I don't know where to place this utility class. Ideally
> I
> would place it in the test branch of module A but then it will not be
> inherited by sub-modules that depend on A say B and C. On the other hand
> if
> I place it under the java branch of module A, then A will compile/runtime
> depend on JUnit which I want to avoid at all costs.
> 
> I remember I had this same problem trying to define reusable test fixtures
> classes but in the hurry I ended up duplicating the fixture classes under
> each sub-module.
> 
> TIA,
> Regards,
> Giovanni
> 
> 
> 
> ---------------------------------------------------------------------
> 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




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


RE: where to place Test support/reusable fixture classes?

Posted by Jeff Jensen <je...@upstairstechnology.com>.
I suggest creating a separate project, e.g. "TestFramework", and place those
types of reusable test classes in its src/main/java.  Then, the other
projects can depend on it for the test scope.


-----Original Message-----
From: Giovanni Azua [mailto:bravegag@swissonline.ch] 
Sent: Friday, January 09, 2009 1:15 PM
To: 'Maven Users List'
Subject: where to place Test support/reusable fixture classes?

Hi,

I have a multi module project and in one of the top nodes of the dependency
tree I would like to place a Test support class i.e.

AbstractHibernateHSQLTestCase extends junit.framework.TestCase

This class provides automatic database shutdown of HSQL in memory based test
cases to prevent the creation of the inconvenient test.lck and test.log
files.

My problem is that I don't know where to place this utility class. Ideally I
would place it in the test branch of module A but then it will not be
inherited by sub-modules that depend on A say B and C. On the other hand if
I place it under the java branch of module A, then A will compile/runtime
depend on JUnit which I want to avoid at all costs.

I remember I had this same problem trying to define reusable test fixtures
classes but in the hurry I ended up duplicating the fixture classes under
each sub-module.

TIA,
Regards,
Giovanni



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