You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Nelz <ne...@gmail.com> on 2007/05/22 20:21:21 UTC

Question: Unit and Integration testing of a WAR

Ok guys...

Am I running against "best practices" here?  Is that why this is so hard?

I have a simple-ish project.  The project artifact is a WAR file.  I
would like to Unit Test the code before it gets packaged, and I would
like to run Integration Tests after it gets packaged.

The Sonatype book
(http://www.sonatype.com/book/j2ee.html#integration_testing) seems to
be advocating the "hijacking" of the "compile:testCompile" and
"surefire:test" phases.  But, it seems to assume the tests are in the
standard /src/test/java directory for the integration tests...  (The
difference is that they are working on a multi-module EAR artifact,
and I am working within a single-module WAR artifact...)

I would like to put unit tests in /src/test/java and integration test
in /src/itest/java, and have both sets run in my single project, in
the correct phases.

Does anyone have any insight?

- Nelz

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


Re: Question: Unit and Integration testing of a WAR

Posted by Nick Stolwijk <ni...@planet.nl>.
With most of my problems with Maven it is a combination of:

- Better builds with Maven e-book [1]
- Sonatype e-book [2]
- The plugin documentation [3] [4]
- The Maven 2 IRC channel [5]
And offcourse, this userlist, maven 2 and plugins sourcecode

Hth,

Nick Stolwijk

[1] http://www.mergere.com/m2book_download.jsp
[2] http://www.sonatype.com/book
[3] http://maven.apache.org/plugins/index.html
[4] http://mojo.codehaus.org/
[5] irc.codehaus.org#maven

Nelz wrote:
> Nick, et al...
>
> Thanks for the suggestion...
>
> But I have to ask a meta-question: how was I supposed to ever find
> that myself...?  It's nowhere in the Surefire plugin documentation...
> I still don't even know that it will work, nor does the documentation
> give any hint that it might.
>
> And to bring the discussion back to specifics, this suggestion still
> doesn't answer my compilation problems, nor does it answer if I am
> going against "best practices"...  Does anyone have any feedback on
> those points?
>
> - Nelz
>
> On 5/22/07, Nick Stolwijk <ni...@planet.nl> wrote:
>> Maybe this'll work:
>>
>> <plugin>
>>     <groupId>org.apache.maven.plugins</groupId>
>>     <artifactId>maven-surefire-plugin</artifactId>
>>     <version>2.3</version>
>>     <executions>
>>          <execution>
>>              <id>surefire-test</id>
>>              <phase>test</phase>
>>          </execution>
>>          <execution>
>>               <id>surefire-integration-test</id>
>>               <phase>integration-test</phase>
>>               <configuration>
>>                   
>> <testSourceDirectory>src/itest/java</testSourceDirectory>
>>               </configuration>
>>          </execution>
>>     </executions>
>> </plugin>
>>
>>
>> Hth,
>>
>> Nick S.
>>
>> Nelz wrote:
>> > Ok guys...
>> >
>> > Am I running against "best practices" here?  Is that why this is so 
>> hard?
>> >
>> > I have a simple-ish project.  The project artifact is a WAR file.  I
>> > would like to Unit Test the code before it gets packaged, and I would
>> > like to run Integration Tests after it gets packaged.
>> >
>> > The Sonatype book
>> > (http://www.sonatype.com/book/j2ee.html#integration_testing) seems to
>> > be advocating the "hijacking" of the "compile:testCompile" and
>> > "surefire:test" phases.  But, it seems to assume the tests are in the
>> > standard /src/test/java directory for the integration tests...  (The
>> > difference is that they are working on a multi-module EAR artifact,
>> > and I am working within a single-module WAR artifact...)
>> >
>> > I would like to put unit tests in /src/test/java and integration test
>> > in /src/itest/java, and have both sets run in my single project, in
>> > the correct phases.
>> >
>> > Does anyone have any insight?
>> >
>> > - Nelz
>> >
>> > ---------------------------------------------------------------------
>> > 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: Question: Unit and Integration testing of a WAR

Posted by Nelz <ne...@gmail.com>.
Nick, et al...

Thanks for the suggestion...

But I have to ask a meta-question: how was I supposed to ever find
that myself...?  It's nowhere in the Surefire plugin documentation...
I still don't even know that it will work, nor does the documentation
give any hint that it might.

And to bring the discussion back to specifics, this suggestion still
doesn't answer my compilation problems, nor does it answer if I am
going against "best practices"...  Does anyone have any feedback on
those points?

- Nelz

On 5/22/07, Nick Stolwijk <ni...@planet.nl> wrote:
> Maybe this'll work:
>
> <plugin>
>     <groupId>org.apache.maven.plugins</groupId>
>     <artifactId>maven-surefire-plugin</artifactId>
>     <version>2.3</version>
>     <executions>
>          <execution>
>              <id>surefire-test</id>
>              <phase>test</phase>
>          </execution>
>          <execution>
>               <id>surefire-integration-test</id>
>               <phase>integration-test</phase>
>               <configuration>
>                   <testSourceDirectory>src/itest/java</testSourceDirectory>
>               </configuration>
>          </execution>
>     </executions>
> </plugin>
>
>
> Hth,
>
> Nick S.
>
> Nelz wrote:
> > Ok guys...
> >
> > Am I running against "best practices" here?  Is that why this is so hard?
> >
> > I have a simple-ish project.  The project artifact is a WAR file.  I
> > would like to Unit Test the code before it gets packaged, and I would
> > like to run Integration Tests after it gets packaged.
> >
> > The Sonatype book
> > (http://www.sonatype.com/book/j2ee.html#integration_testing) seems to
> > be advocating the "hijacking" of the "compile:testCompile" and
> > "surefire:test" phases.  But, it seems to assume the tests are in the
> > standard /src/test/java directory for the integration tests...  (The
> > difference is that they are working on a multi-module EAR artifact,
> > and I am working within a single-module WAR artifact...)
> >
> > I would like to put unit tests in /src/test/java and integration test
> > in /src/itest/java, and have both sets run in my single project, in
> > the correct phases.
> >
> > Does anyone have any insight?
> >
> > - Nelz
> >
> > ---------------------------------------------------------------------
> > 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: Question: Unit and Integration testing of a WAR

Posted by Nick Stolwijk <ni...@planet.nl>.
Maybe this'll work:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.3</version>
    <executions>
         <execution>
             <id>surefire-test</id>
             <phase>test</phase>
         </execution>
         <execution>
              <id>surefire-integration-test</id>
              <phase>integration-test</phase>
              <configuration>
                  <testSourceDirectory>src/itest/java</testSourceDirectory>
              </configuration>
         </execution>
    </executions> 
</plugin>


Hth,

Nick S.

Nelz wrote:
> Ok guys...
>
> Am I running against "best practices" here?  Is that why this is so hard?
>
> I have a simple-ish project.  The project artifact is a WAR file.  I
> would like to Unit Test the code before it gets packaged, and I would
> like to run Integration Tests after it gets packaged.
>
> The Sonatype book
> (http://www.sonatype.com/book/j2ee.html#integration_testing) seems to
> be advocating the "hijacking" of the "compile:testCompile" and
> "surefire:test" phases.  But, it seems to assume the tests are in the
> standard /src/test/java directory for the integration tests...  (The
> difference is that they are working on a multi-module EAR artifact,
> and I am working within a single-module WAR artifact...)
>
> I would like to put unit tests in /src/test/java and integration test
> in /src/itest/java, and have both sets run in my single project, in
> the correct phases.
>
> Does anyone have any insight?
>
> - Nelz
>
> ---------------------------------------------------------------------
> 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