You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by to...@gi-de.com on 2008/05/29 16:54:19 UTC

how to separate Unit Tests from Integration-Tests with JUnit 4.x?

Hi, 

Actually, we have mixed JUnit Testcases in our modules - some of them can 
be run "standalone" with no database connection or any other environment, 
others need environment.

I now want to separate those tests into different categories, but I don´t 
want to 
- manually create a DatabaseTestSuite where I need to add all 
database-testcases
- create a new Maven Module to separate the testcases

Can I use JUnit 4.x with its annotations like @RunWith @Ignore and so on 
to do so ?

For example the "simple testcases" should be bound to the "test" phase, 
the "database-testcases" should be bound to the "integration-test" phase.

Any ideas, links, cookbooks?

Thanx, Torsten


Antwort: Re: how to separate Unit Tests from Integration-Tests with JUnit 4.x?

Posted by to...@gi-de.com.
Hi, yes i dont wanted to 

- place the integration-tests in a different module - thats because we 
already have up to 15 modules in our multi-module-build and I guess our 
developers won´t be happy if I move their tests around the world:-)
- rename all the tests afterwards and introduce naming conventions 

The current surefire-plugin only allows to filter by include/exclude 
patterns.
I´m looking for a more flexible way to filter which Tests are executed.

A solution could be to enhance the surefire-plugin, so in can configure 
special org.junit.runner.manipulation.Filter.
These configured filters than have to be applied at 

    protected JUnit4TestSet( Class testClass )
    {
        super( testClass );

        // junitTestRunner = Request.aClass( testClass ).getRunner();
        junitTestRunner = new FilterRequest( Request.aClass( testClass ), 
filter ).getRunner(); 
    }

What do you think? 

torsten





"Kalle Korhonen" <ka...@gmail.com> 
30.05.2008 00:35
Bitte antworten an
"Maven Users List" <us...@maven.apache.org>


An
"Maven Users List" <us...@maven.apache.org>
Kopie

Thema
Re: how to separate Unit Tests from Integration-Tests with JUnit 4.x?






Hmm yes, but Torsten said that was exactly what he wanted to avoid. In
addition to naming conventions for unit & integration tests, we use a
separate module for our heavier, end-to-end functional tests.

Kalle

On Thu, May 29, 2008 at 10:06 AM, Paul Davis <pa...@gmail.com> wrote:

> Another option is to place the integration tests into a separate module.
>
> On Thu, May 29, 2008 at 8:12 AM, Kalle Korhonen <
> kalle.o.korhonen@gmail.com>
> wrote:
>
> > Standard answer is with naming convention, see
> > http://www.mail-archive.com/users@maven.apache.org/msg81355.html.
> >
> > Kalle
> >
> > On Thu, May 29, 2008 at 7:54 AM, <to...@gi-de.com> wrote:
> >
> > > Hi,
> > >
> > > Actually, we have mixed JUnit Testcases in our modules - some of 
them
> can
> > > be run "standalone" with no database connection or any other
> environment,
> > > others need environment.
> > >
> > > I now want to separate those tests into different categories, but I
> don´t
> > > want to
> > > - manually create a DatabaseTestSuite where I need to add all
> > > database-testcases
> > > - create a new Maven Module to separate the testcases
> > >
> > > Can I use JUnit 4.x with its annotations like @RunWith @Ignore and 
so
> on
> > > to do so ?
> > >
> > > For example the "simple testcases" should be bound to the "test" 
phase,
> > > the "database-testcases" should be bound to the "integration-test"
> phase.
> > >
> > > Any ideas, links, cookbooks?
> > >
> > > Thanx, Torsten
> > >
> > >
> >
>


Re: how to separate Unit Tests from Integration-Tests with JUnit 4.x?

Posted by Kalle Korhonen <ka...@gmail.com>.
Hmm yes, but Torsten said that was exactly what he wanted to avoid. In
addition to naming conventions for unit & integration tests, we use a
separate module for our heavier, end-to-end functional tests.

Kalle


On Thu, May 29, 2008 at 10:06 AM, Paul Davis <pa...@gmail.com> wrote:

> Another option is to place the integration tests into a separate module.
>
> On Thu, May 29, 2008 at 8:12 AM, Kalle Korhonen <
> kalle.o.korhonen@gmail.com>
> wrote:
>
> > Standard answer is with naming convention, see
> > http://www.mail-archive.com/users@maven.apache.org/msg81355.html.
> >
> > Kalle
> >
> > On Thu, May 29, 2008 at 7:54 AM, <to...@gi-de.com> wrote:
> >
> > > Hi,
> > >
> > > Actually, we have mixed JUnit Testcases in our modules - some of them
> can
> > > be run "standalone" with no database connection or any other
> environment,
> > > others need environment.
> > >
> > > I now want to separate those tests into different categories, but I
> don´t
> > > want to
> > > - manually create a DatabaseTestSuite where I need to add all
> > > database-testcases
> > > - create a new Maven Module to separate the testcases
> > >
> > > Can I use JUnit 4.x with its annotations like @RunWith @Ignore and so
> on
> > > to do so ?
> > >
> > > For example the "simple testcases" should be bound to the "test" phase,
> > > the "database-testcases" should be bound to the "integration-test"
> phase.
> > >
> > > Any ideas, links, cookbooks?
> > >
> > > Thanx, Torsten
> > >
> > >
> >
>

Re: how to separate Unit Tests from Integration-Tests with JUnit 4.x?

Posted by Paul Davis <pa...@gmail.com>.
Another option is to place the integration tests into a separate module.

On Thu, May 29, 2008 at 8:12 AM, Kalle Korhonen <ka...@gmail.com>
wrote:

> Standard answer is with naming convention, see
> http://www.mail-archive.com/users@maven.apache.org/msg81355.html.
>
> Kalle
>
> On Thu, May 29, 2008 at 7:54 AM, <to...@gi-de.com> wrote:
>
> > Hi,
> >
> > Actually, we have mixed JUnit Testcases in our modules - some of them can
> > be run "standalone" with no database connection or any other environment,
> > others need environment.
> >
> > I now want to separate those tests into different categories, but I don´t
> > want to
> > - manually create a DatabaseTestSuite where I need to add all
> > database-testcases
> > - create a new Maven Module to separate the testcases
> >
> > Can I use JUnit 4.x with its annotations like @RunWith @Ignore and so on
> > to do so ?
> >
> > For example the "simple testcases" should be bound to the "test" phase,
> > the "database-testcases" should be bound to the "integration-test" phase.
> >
> > Any ideas, links, cookbooks?
> >
> > Thanx, Torsten
> >
> >
>

Re: how to separate Unit Tests from Integration-Tests with JUnit 4.x?

Posted by Kalle Korhonen <ka...@gmail.com>.
Standard answer is with naming convention, see
http://www.mail-archive.com/users@maven.apache.org/msg81355.html.

Kalle

On Thu, May 29, 2008 at 7:54 AM, <to...@gi-de.com> wrote:

> Hi,
>
> Actually, we have mixed JUnit Testcases in our modules - some of them can
> be run "standalone" with no database connection or any other environment,
> others need environment.
>
> I now want to separate those tests into different categories, but I don´t
> want to
> - manually create a DatabaseTestSuite where I need to add all
> database-testcases
> - create a new Maven Module to separate the testcases
>
> Can I use JUnit 4.x with its annotations like @RunWith @Ignore and so on
> to do so ?
>
> For example the "simple testcases" should be bound to the "test" phase,
> the "database-testcases" should be bound to the "integration-test" phase.
>
> Any ideas, links, cookbooks?
>
> Thanx, Torsten
>
>