You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Frederic Camblor <fc...@gmail.com> on 2009/09/14 17:21:47 UTC

Cobertura in EAR artefacts

Hi folks !
I'm facing a problematic concerning the cobertura report.

Suppose we have an EAR Application with :
- A Business module
- A Web module

Web layer uses the Business Layer.
Unit tests are made in both Business and WEB modules.

When I run tests on WEB module, some Business classes are called during the
test process.

My problem is : I don't know how to parameterize cobertura in order to
aggregate results from Business layer during the Web Layer tests execution.

That is to say, for now on, I've only 10% of test coverage on Business layer
and 50% of test coverage on Web layer ... because they are aggregated *
independently* !
Although I'm sure I could have almost ~40% of test coverage on Business
layer with the execution of tests on Web layer :(

Someone already faced the problem ?

Thanks in advance
Frederic

Re: Cobertura in EAR artefacts

Posted by Roland Asmann <Ro...@cfc.at>.
Ah, this unfortunately means that you *CAN'T* run the site-build as you 
normally would, since the reports are generated on a per-module basis and you 
would 'update;  your results with a later test.

So, it's best to 'manually' test your coverage or have 2 'passes' of maven's 
site-build to include the updated cobertura-results.

And maybe it needs mentioning, maybe not: stay away from the 'clean'-goal 
between these passes! :-)


On Monday 14 September 2009 18:03, Roland Asmann wrote:
> Couldn't you just package the cobertura-jars in your EAR and run
> integration-tests on them? I believe that Cobertura writes all calls to the
> respective data-files when methods are called... At least, last time I
> checked this worked for me... :-)
>
> To use the cobertura-jars, just add the cobertura:instrument call in the
> POM and Maven will handle the rest... Be carefull though, it's probably
> best to do this in a test-profile, since your normal artifacts will now
> have Cobertura-classes in them!
>
> POM-snippet:
> ---------- SNIPPET ----------
>   <profiles>
>     <profile>
>       <id>test</id>
>       <build>
>         <plugins>
>           <plugin>
>             <groupId>org.codehaus.mojo</groupId>
>             <artifactId>cobertura-maven-plugin</artifactId>
>             <version>2.3</version>
>             <executions>
>               <execution>
>                 <id>instrument</id>
>                 <phase>process-classes</phase>
>                 <goals>
>                   <goal>instrument</goal>
>                 </goals>
>               </execution>
>             </executions>
>           </plugin>
>         </plugins>
>       </build>
>       <dependencies>
>         <dependency>
>           <groupId>net.sourceforge.cobertura</groupId>
>           <artifactId>cobertura</artifactId>
>           <version>1.9.2</version>
>         </dependency>
>       </dependencies>
>     </profile>
>   </profiles>
> ----------- SNIPPET ENDS ----------
>
> On Monday 14 September 2009 17:21, Frederic Camblor wrote:
> > Hi folks !
> > I'm facing a problematic concerning the cobertura report.
> >
> > Suppose we have an EAR Application with :
> > - A Business module
> > - A Web module
> >
> > Web layer uses the Business Layer.
> > Unit tests are made in both Business and WEB modules.
> >
> > When I run tests on WEB module, some Business classes are called during
> > the test process.
> >
> > My problem is : I don't know how to parameterize cobertura in order to
> > aggregate results from Business layer during the Web Layer tests
> > execution.
> >
> > That is to say, for now on, I've only 10% of test coverage on Business
> > layer and 50% of test coverage on Web layer ... because they are
> > aggregated * independently* !
> > Although I'm sure I could have almost ~40% of test coverage on Business
> > layer with the execution of tests on Web layer :(
> >
> > Someone already faced the problem ?
> >
> > Thanks in advance
> > Frederic

-- 
Roland Asmann

CFC Informationssysteme Entwicklungsgesellschaft m.b.H
Bäckerstrasse 1/2/7
A-1010 Wien
FN 266155f, Handelsgericht Wien

Tel.: +43/1/513 88 77 - 27
Fax.: +43/1/513 88 62
Email: Roland.Asmann@cfc.at
Web: www.cfc.at

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


Re: Cobertura in EAR artefacts

Posted by Roland Asmann <Ro...@cfc.at>.
Couldn't you just package the cobertura-jars in your EAR and run 
integration-tests on them? I believe that Cobertura writes all calls to the 
respective data-files when methods are called... At least, last time I 
checked this worked for me... :-)

To use the cobertura-jars, just add the cobertura:instrument call in the POM 
and Maven will handle the rest... Be carefull though, it's probably best to 
do this in a test-profile, since your normal artifacts will now have 
Cobertura-classes in them!

POM-snippet:
---------- SNIPPET ----------
  <profiles>
    <profile>
      <id>test</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>cobertura-maven-plugin</artifactId>
            <version>2.3</version>
            <executions>
              <execution>
                <id>instrument</id>
                <phase>process-classes</phase>
                <goals>
                  <goal>instrument</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
      <dependencies>
        <dependency>
          <groupId>net.sourceforge.cobertura</groupId>
          <artifactId>cobertura</artifactId>
          <version>1.9.2</version>
        </dependency>
      </dependencies>
    </profile>
  </profiles>
----------- SNIPPET ENDS ----------



On Monday 14 September 2009 17:21, Frederic Camblor wrote:
> Hi folks !
> I'm facing a problematic concerning the cobertura report.
>
> Suppose we have an EAR Application with :
> - A Business module
> - A Web module
>
> Web layer uses the Business Layer.
> Unit tests are made in both Business and WEB modules.
>
> When I run tests on WEB module, some Business classes are called during the
> test process.
>
> My problem is : I don't know how to parameterize cobertura in order to
> aggregate results from Business layer during the Web Layer tests execution.
>
> That is to say, for now on, I've only 10% of test coverage on Business
> layer and 50% of test coverage on Web layer ... because they are aggregated
> * independently* !
> Although I'm sure I could have almost ~40% of test coverage on Business
> layer with the execution of tests on Web layer :(
>
> Someone already faced the problem ?
>
> Thanks in advance
> Frederic

-- 
Roland Asmann

CFC Informationssysteme Entwicklungsgesellschaft m.b.H
Bäckerstrasse 1/2/7
A-1010 Wien
FN 266155f, Handelsgericht Wien

Tel.: +43/1/513 88 77 - 27
Fax.: +43/1/513 88 62
Email: Roland.Asmann@cfc.at
Web: www.cfc.at

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