You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Mick Knutson <mi...@gmail.com> on 2008/03/21 22:36:45 UTC

[m2] cobertura code coverage for dbunit test classes with testNG and OpenJPA?

I have a Spring, OpenJPA, DBUnit, TestNG, HSQL build with Maven 2.0.8 and
there are 20 DAO tests that now pass. I am trying to now add cobertura to
this. I have used Cobertura extensively in the past, but never with DBUnit.

So, I am getting the report to generate, but everything is zero. So it
appears that nothing was instrumented.
Here is my surefire and cobertura plugins:

<reporting>....
            <plugin>
                <artifactId>maven-surefire-report-plugin</artifactId>
                <version>2.4.2</version>
                <configuration>
                    <includes>
                        <include implementation="java.lang.String
">**/*.java</include>
                    </includes>
                    <excludes>
                        <exclude implementation="java.lang.String
">**/*Point*.java</exclude>
                    </excludes>
                    <systemProperties>
                        <property>
                            <name>net.sourceforge.cobertura.datafile</name>

<value>${basedir}/target/cobertura/cobertura.ser</value>
                        </property>
                    </systemProperties>
                    <argLine>-Xmx256m</argLine>
                    <testFailureIgnore>true</testFailureIgnore>
                </configuration>
            </plugin>

<plugins>...


            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>dbunit-maven-plugin</artifactId>
                <version>1.0-beta-1</version>
                <configuration>
                    <dataTypeFactoryName>${dbunit.dataTypeFactoryName
}</dataTypeFactoryName>
                    <driver>${jdbc.driverClassName}</driver>
                    <username>${jdbc.username}</username>
                    <password>${jdbc.password}</password>
                    <url>${jdbc.url}</url>
                    <src>src/test/resources/test-data.xml</src>
                    <type>${dbunit.operation.type}</type>
                    <schema>${dbunit.schema}</schema>
                    <skip>${maven.test.skip}</skip>
                </configuration>
                <executions>
                    <execution>
                        <phase>test-compile</phase>
                        <goals>
                            <goal>operation</goal>
                        </goals>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>${jdbc.groupId}</groupId>
                        <artifactId>${jdbc.artifactId}</artifactId>
                        <version>${jdbc.version}</version>
                    </dependency>
                </dependencies>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>cobertura-maven-plugin</artifactId>
                <version>2.2</version>

                <configuration>
                    <formats>
                        <format>xml</format>
                        <format>html</format>
                    </formats>

                    <instrumentation>
                        <ignores>
                            <ignore>org.apache.commons.logging.*</ignore>
                        </ignores>
                        <excludes>
                            <exclude>com/**/*Test.class</exclude>

                            <exclude>org/apache/log4j/**/*.class</exclude>

                        </excludes>
                    </instrumentation>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>clean</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>openjpa-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>JPA Enhance</id>
                        <phase>process-classes</phase>
                        <goals>
                            <goal>enhance</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <toolProperties>
                        <property>
                            <name>addDefaultConstructor</name>
                            <value>true</value>
                        </property>
                        <property>
                            <name>enforcePropertyRestrictions</name>
                            <value>true</value>
                        </property>
                    </toolProperties>
                </configuration>
            </plugin>



When I run mvn site:site to a txt file, I started looking through the trace
and noticed:

*[INFO] [cobertura:instrument]
[INFO] Cobertura 1.9 - GNU GPL License (NO WARRANTY) - See COPYRIGHT file
Cobertura: Loaded information on 13 classes.
Instrumenting 13 files to
C:\opt\temp\myproject\core\target\generated-classes\cobertura
Cobertura: Saved information on 13 classes.
Instrument time: 266ms

[INFO] Instrumentation was successful.
*


So am I missing something with DBUnit plugin, or openJPA plugin as to point
to *target\generated-classes\cobertura instead of **target\classes ???


*--
Thanks,
Mick Knutson

http://www.baselogic.com
http://www.blincmagazine.com
http://www.linkedin.com/in/mickknutson
http://www.djmick.com
http://www.myspace.com/mickknutson
http://www.myspace.com/BLiNCMagazine
http://tahoe.baselogic.com
---

Re: [m2] cobertura code coverage for dbunit test classes with testNG and OpenJPA?

Posted by Mick Knutson <mi...@gmail.com>.
I am still having an issue with this...
Can someone please help me track down the issue here? I do not get any
errors, but I just get no test coverage (everything is at zero).


On Mon, Mar 31, 2008 at 1:32 PM, Mick Knutson <mi...@gmail.com> wrote:

> So I am still having this intermittant issue.
> I looked at http://mojo.codehaus.org/cobertura-maven-plugin/usage.html and
> have a small question about the
>
> <goal>clean</goal>
>
> So does this mean that cobertura instruments the code during the clean?
>
> I am suspecting that there is an issue with my openJPA plugin trying to
> run some instrumentation (or something) on my code. Is this conflicting with
> Cobertura?
>
>
>
>
> On Mon, Mar 24, 2008 at 10:42 AM, Mick Knutson <mi...@gmail.com>
> wrote:
>
> > So I need to mention again, I am using the openJPA plugin to enhance the
> > byte code in this project.
> >
> > But it seems strange. I uncommented <goal>check</goal> then got an error
> > as I am under 25% coverage (as expected), then commented it out again so the
> > site:site would complete. Then BAM! I got my coverage report.
> >
> > Then I ran another clean install, and the report stopped again. So I
> > uncommented <goal>check</goal>, ran the build again that failed, commented
> > <goal>check</goal> again, and BAM it worked again.
> >
> > I am not fully sure whate the trick is, but it seems I need to not clean
> > the build, and run the plugin with <goal>check</goal> in order to make this
> > work.
> >
> > Has anyone run into this as well?
> >
> >
> > On Mon, Mar 24, 2008 at 4:20 AM, Erez Nahir <er...@gmail.com>
> > wrote:
> >
> > > Hi Mick,
> > >
> > > We have surefire 2.4.2 + testng + cobertura 2.2 works.
> > > Your cofiguration looks fine to me, but, I'm missing the cobertura
> > > definition in the <reporting> section.
> > > The only difference I see from out build (other then the need to add
> > > cobertuar to reporting section) is usage of ${basedir} as value. Try
> > > to
> > > remove it, I know surefire has some issues passing values of
> > > ${properties}.
> > >
> > > Here is what we have:
> > > In surefire plugin:
> > >                <property>
> > >                 <name>net.sourceforge.cobertura.datafile</name>
> > >                  <value>target/cobertura/cobertura.ser</value>
> > >               </property>
> > >             </systemProperties>
> > > In the reporting section:
> > >      <reporting>
> > >         <plugins>
> > > ...
> > > ...
> > >          <plugin>
> > >            <groupId>org.codehaus.mojo</groupId>
> > >             <artifactId>cobertura-maven-plugin</artifactId>
> > >            <version>2.2</version>
> > >           </plugin>
> > >        </plugins>
> > >      </reporting>
> > > HTH,
> > > Erez.
> > > On Sun, Mar 23, 2008 at 12:48 PM, Mick Knutson <mi...@gmail.com>
> > > wrote:
> > >
> > > > Anyone have any ideas?
> > > > I have tried cobertura 2.0 and 2.2 maven plugin and still the same
> > > result.
> > > >
> > > >
> > > > On Fri, Mar 21, 2008 at 2:36 PM, Mick Knutson <mickknutson@gmail.com
> > > >
> > > > wrote:
> > > >
> > > > > I have a Spring, OpenJPA, DBUnit, TestNG, HSQL build with Maven
> > > 2.0.8and
> > > > > there are 20 DAO tests that now pass. I am trying to now add
> > > cobertura
> > > > to
> > > > > this. I have used Cobertura extensively in the past, but never
> > > with
> > > > DBUnit.
> > > > >
> > > > > So, I am getting the report to generate, but everything is zero.
> > > So it
> > > > > appears that nothing was instrumented.
> > > > > Here is my surefire and cobertura plugins:
> > > > >
> > > > > <reporting>....
> > > > >             <plugin>
> > > > >
> > > <artifactId>maven-surefire-report-plugin</artifactId>
> > > > >                 <version>2.4.2</version>
> > > > >                 <configuration>
> > > > >                     <includes>
> > > > >                         <include implementation="java.lang.String
> > > > > ">**/*.java</include>
> > > > >                     </includes>
> > > > >                     <excludes>
> > > > >                         <exclude implementation="java.lang.String
> > > > > ">**/*Point*.java</exclude>
> > > > >                     </excludes>
> > > > >                     <systemProperties>
> > > > >                         <property>
> > > > >
> > > <name>net.sourceforge.cobertura.datafile
> > > > > </name>
> > > > >
> > > > > <value>${basedir}/target/cobertura/cobertura.ser</value>
> > > > >                         </property>
> > > > >                     </systemProperties>
> > > > >                     <argLine>-Xmx256m</argLine>
> > > > >                     <testFailureIgnore>true</testFailureIgnore>
> > > > >                 </configuration>
> > > > >             </plugin>
> > > > >
> > > > > <plugins>...
> > > > >
> > > > >
> > > > >             <plugin>
> > > > >                 <groupId>org.codehaus.mojo</groupId>
> > > > >                 <artifactId>dbunit-maven-plugin</artifactId>
> > > > >                 <version>1.0-beta-1</version>
> > > > >                 <configuration>
> > > > >
> > > <dataTypeFactoryName>${dbunit.dataTypeFactoryName
> > > > > }</dataTypeFactoryName>
> > > > >                     <driver>${jdbc.driverClassName}</driver>
> > > > >                     <username>${jdbc.username}</username>
> > > > >                     <password>${jdbc.password}</password>
> > > > >                     <url>${jdbc.url}</url>
> > > > >                     <src>src/test/resources/test-data.xml</src>
> > > > >                     <type>${dbunit.operation.type}</type>
> > > > >                     <schema>${dbunit.schema}</schema>
> > > > >                     <skip>${maven.test.skip}</skip>
> > > > >                 </configuration>
> > > > >                 <executions>
> > > > >                     <execution>
> > > > >                         <phase>test-compile</phase>
> > > > >                         <goals>
> > > > >                             <goal>operation</goal>
> > > > >                         </goals>
> > > > >                     </execution>
> > > > >                 </executions>
> > > > >                 <dependencies>
> > > > >                     <dependency>
> > > > >                         <groupId>${jdbc.groupId}</groupId>
> > > > >
> > > <artifactId>${jdbc.artifactId}</artifactId>
> > > > >                         <version>${jdbc.version}</version>
> > > > >                     </dependency>
> > > > >                 </dependencies>
> > > > >             </plugin>
> > > > >             <plugin>
> > > > >                 <groupId>org.codehaus.mojo</groupId>
> > > > >                 <artifactId>cobertura-maven-plugin</artifactId>
> > > > >                 <version>2.2</version>
> > > > >
> > > > >                 <configuration>
> > > > >                     <formats>
> > > > >                         <format>xml</format>
> > > > >                         <format>html</format>
> > > > >                     </formats>
> > > > >
> > > > >                     <instrumentation>
> > > > >                         <ignores>
> > > > >                             <ignore>org.apache.commons.logging.*
> > > > </ignore>
> > > > >                         </ignores>
> > > > >                         <excludes>
> > > > >                             <exclude>com/**/*Test.class</exclude>
> > > > >
> > > > >
> > > > <exclude>org/apache/log4j/**/*.class</exclude>
> > > > >
> > > > >                         </excludes>
> > > > >                     </instrumentation>
> > > > >                 </configuration>
> > > > >                 <executions>
> > > > >                     <execution>
> > > > >                         <goals>
> > > > >                             <goal>clean</goal>
> > > > >                         </goals>
> > > > >                     </execution>
> > > > >                 </executions>
> > > > >             </plugin>
> > > > >
> > > > >             <plugin>
> > > > >                 <groupId>org.codehaus.mojo</groupId>
> > > > >                 <artifactId>openjpa-maven-plugin</artifactId>
> > > > >                 <executions>
> > > > >                     <execution>
> > > > >                         <id>JPA Enhance</id>
> > > > >                         <phase>process-classes</phase>
> > > > >                         <goals>
> > > > >                             <goal>enhance</goal>
> > > > >                         </goals>
> > > > >                     </execution>
> > > > >                 </executions>
> > > > >                 <configuration>
> > > > >                     <toolProperties>
> > > > >                         <property>
> > > > >                             <name>addDefaultConstructor</name>
> > > > >                             <value>true</value>
> > > > >                         </property>
> > > > >                         <property>
> > > > >
> > > <name>enforcePropertyRestrictions</name>
> > > > >                             <value>true</value>
> > > > >                         </property>
> > > > >                     </toolProperties>
> > > > >                 </configuration>
> > > > >             </plugin>
> > > > >
> > > > >
> > > > >
> > > > > When I run mvn site:site to a txt file, I started looking through
> > > the
> > > > > trace and noticed:
> > > > >
> > > > > *[INFO] [cobertura:instrument]
> > > > > [INFO] Cobertura 1.9 - GNU GPL License (NO WARRANTY) - See
> > > COPYRIGHT
> > > > file
> > > > > Cobertura: Loaded information on 13 classes.
> > > > > Instrumenting 13 files to
> > > > > C:\opt\temp\myproject\core\target\generated-classes\cobertura
> > > > > Cobertura: Saved information on 13 classes.
> > > > > Instrument time: 266ms
> > > > >
> > > > > [INFO] Instrumentation was successful.
> > > > > *
> > > > >
> > > > >
> > > > > So am I missing something with DBUnit plugin, or openJPA plugin as
> > > to
> > > > > point to *target\generated-classes\cobertura instead of
> > > **target\classes
> > > > > ???
> > > > >
> > > > >
> > > > > *--
> > > > > Thanks,
> > > > > Mick Knutson
> > > > >
> > > > > http://www.baselogic.com
> > > > > http://www.blincmagazine.com
> > > > > http://www.linkedin.com/in/mickknutson
> > > > > http://www.djmick.com
> > > > > http://www.myspace.com/mickknutson
> > > > > http://www.myspace.com/BLiNCMagazine
> > > > > http://tahoe.baselogic.com
> > > > > ---
> > > >
> > > >
> > > >
> > > >
> > > > --
> > > >  Thanks,
> > > > Mick Knutson
> > > >
> > > > http://www.baselogic.com
> > > > http://www.blincmagazine.com
> > > > http://www.linkedin.com/in/mickknutson
> > > > http://www.djmick.com
> > > > http://www.myspace.com/mickknutson
> > > > http://www.myspace.com/BLiNCMagazine
> > > > http://tahoe.baselogic.com
> > > > ---
> > > >
> > >
> >
> >
> >
> > --
> > Thanks,
> > Mick Knutson
> >
> > http://www.baselogic.com
> > http://www.blincmagazine.com
> > http://www.linkedin.com/in/mickknutson
> > http://www.djmick.com
> > http://www.myspace.com/mickknutson
> > http://www.myspace.com/BLiNCMagazine
> > http://tahoe.baselogic.com
> > ---
> >
>
>
>
> --
> Thanks,
> Mick Knutson
>
> http://www.baselogic.com
> http://www.blincmagazine.com
> http://www.linkedin.com/in/mickknutson
> http://www.djmick.com
> http://www.myspace.com/mickknutson
> http://www.myspace.com/BLiNCMagazine
> http://tahoe.baselogic.com
> ---
>



-- 
Thanks,
Mick Knutson

http://www.baselogic.com
http://www.blincmagazine.com
http://www.linkedin.com/in/mickknutson
http://www.djmick.com
http://www.myspace.com/mickknutson
http://www.myspace.com/BLiNCMagazine
http://tahoe.baselogic.com
---

Re: [m2] cobertura code coverage for dbunit test classes with testNG and OpenJPA?

Posted by Mick Knutson <mi...@gmail.com>.
So I am still having this intermittant issue.
I looked at http://mojo.codehaus.org/cobertura-maven-plugin/usage.html and
have a small question about the

<goal>clean</goal>

So does this mean that cobertura instruments the code during the clean?

I am suspecting that there is an issue with my openJPA plugin trying to run
some instrumentation (or something) on my code. Is this conflicting with
Cobertura?



On Mon, Mar 24, 2008 at 10:42 AM, Mick Knutson <mi...@gmail.com>
wrote:

> So I need to mention again, I am using the openJPA plugin to enhance the
> byte code in this project.
>
> But it seems strange. I uncommented <goal>check</goal> then got an error
> as I am under 25% coverage (as expected), then commented it out again so the
> site:site would complete. Then BAM! I got my coverage report.
>
> Then I ran another clean install, and the report stopped again. So I
> uncommented <goal>check</goal>, ran the build again that failed, commented
> <goal>check</goal> again, and BAM it worked again.
>
> I am not fully sure whate the trick is, but it seems I need to not clean
> the build, and run the plugin with <goal>check</goal> in order to make this
> work.
>
> Has anyone run into this as well?
>
>
> On Mon, Mar 24, 2008 at 4:20 AM, Erez Nahir <er...@gmail.com> wrote:
>
> > Hi Mick,
> >
> > We have surefire 2.4.2 + testng + cobertura 2.2 works.
> > Your cofiguration looks fine to me, but, I'm missing the cobertura
> > definition in the <reporting> section.
> > The only difference I see from out build (other then the need to add
> > cobertuar to reporting section) is usage of ${basedir} as value. Try to
> > remove it, I know surefire has some issues passing values of
> > ${properties}.
> >
> > Here is what we have:
> > In surefire plugin:
> >                <property>
> >                 <name>net.sourceforge.cobertura.datafile</name>
> >                  <value>target/cobertura/cobertura.ser</value>
> >               </property>
> >             </systemProperties>
> > In the reporting section:
> >      <reporting>
> >         <plugins>
> > ...
> > ...
> >          <plugin>
> >            <groupId>org.codehaus.mojo</groupId>
> >             <artifactId>cobertura-maven-plugin</artifactId>
> >            <version>2.2</version>
> >           </plugin>
> >        </plugins>
> >      </reporting>
> > HTH,
> > Erez.
> > On Sun, Mar 23, 2008 at 12:48 PM, Mick Knutson <mi...@gmail.com>
> > wrote:
> >
> > > Anyone have any ideas?
> > > I have tried cobertura 2.0 and 2.2 maven plugin and still the same
> > result.
> > >
> > >
> > > On Fri, Mar 21, 2008 at 2:36 PM, Mick Knutson <mi...@gmail.com>
> > > wrote:
> > >
> > > > I have a Spring, OpenJPA, DBUnit, TestNG, HSQL build with Maven
> > 2.0.8and
> > > > there are 20 DAO tests that now pass. I am trying to now add
> > cobertura
> > > to
> > > > this. I have used Cobertura extensively in the past, but never with
> > > DBUnit.
> > > >
> > > > So, I am getting the report to generate, but everything is zero. So
> > it
> > > > appears that nothing was instrumented.
> > > > Here is my surefire and cobertura plugins:
> > > >
> > > > <reporting>....
> > > >             <plugin>
> > > >
> > <artifactId>maven-surefire-report-plugin</artifactId>
> > > >                 <version>2.4.2</version>
> > > >                 <configuration>
> > > >                     <includes>
> > > >                         <include implementation="java.lang.String
> > > > ">**/*.java</include>
> > > >                     </includes>
> > > >                     <excludes>
> > > >                         <exclude implementation="java.lang.String
> > > > ">**/*Point*.java</exclude>
> > > >                     </excludes>
> > > >                     <systemProperties>
> > > >                         <property>
> > > >                             <name>net.sourceforge.cobertura.datafile
> > > > </name>
> > > >
> > > > <value>${basedir}/target/cobertura/cobertura.ser</value>
> > > >                         </property>
> > > >                     </systemProperties>
> > > >                     <argLine>-Xmx256m</argLine>
> > > >                     <testFailureIgnore>true</testFailureIgnore>
> > > >                 </configuration>
> > > >             </plugin>
> > > >
> > > > <plugins>...
> > > >
> > > >
> > > >             <plugin>
> > > >                 <groupId>org.codehaus.mojo</groupId>
> > > >                 <artifactId>dbunit-maven-plugin</artifactId>
> > > >                 <version>1.0-beta-1</version>
> > > >                 <configuration>
> > > >                     <dataTypeFactoryName>${
> > dbunit.dataTypeFactoryName
> > > > }</dataTypeFactoryName>
> > > >                     <driver>${jdbc.driverClassName}</driver>
> > > >                     <username>${jdbc.username}</username>
> > > >                     <password>${jdbc.password}</password>
> > > >                     <url>${jdbc.url}</url>
> > > >                     <src>src/test/resources/test-data.xml</src>
> > > >                     <type>${dbunit.operation.type}</type>
> > > >                     <schema>${dbunit.schema}</schema>
> > > >                     <skip>${maven.test.skip}</skip>
> > > >                 </configuration>
> > > >                 <executions>
> > > >                     <execution>
> > > >                         <phase>test-compile</phase>
> > > >                         <goals>
> > > >                             <goal>operation</goal>
> > > >                         </goals>
> > > >                     </execution>
> > > >                 </executions>
> > > >                 <dependencies>
> > > >                     <dependency>
> > > >                         <groupId>${jdbc.groupId}</groupId>
> > > >                         <artifactId>${jdbc.artifactId}</artifactId>
> > > >                         <version>${jdbc.version}</version>
> > > >                     </dependency>
> > > >                 </dependencies>
> > > >             </plugin>
> > > >             <plugin>
> > > >                 <groupId>org.codehaus.mojo</groupId>
> > > >                 <artifactId>cobertura-maven-plugin</artifactId>
> > > >                 <version>2.2</version>
> > > >
> > > >                 <configuration>
> > > >                     <formats>
> > > >                         <format>xml</format>
> > > >                         <format>html</format>
> > > >                     </formats>
> > > >
> > > >                     <instrumentation>
> > > >                         <ignores>
> > > >                             <ignore>org.apache.commons.logging.*
> > > </ignore>
> > > >                         </ignores>
> > > >                         <excludes>
> > > >                             <exclude>com/**/*Test.class</exclude>
> > > >
> > > >
> > > <exclude>org/apache/log4j/**/*.class</exclude>
> > > >
> > > >                         </excludes>
> > > >                     </instrumentation>
> > > >                 </configuration>
> > > >                 <executions>
> > > >                     <execution>
> > > >                         <goals>
> > > >                             <goal>clean</goal>
> > > >                         </goals>
> > > >                     </execution>
> > > >                 </executions>
> > > >             </plugin>
> > > >
> > > >             <plugin>
> > > >                 <groupId>org.codehaus.mojo</groupId>
> > > >                 <artifactId>openjpa-maven-plugin</artifactId>
> > > >                 <executions>
> > > >                     <execution>
> > > >                         <id>JPA Enhance</id>
> > > >                         <phase>process-classes</phase>
> > > >                         <goals>
> > > >                             <goal>enhance</goal>
> > > >                         </goals>
> > > >                     </execution>
> > > >                 </executions>
> > > >                 <configuration>
> > > >                     <toolProperties>
> > > >                         <property>
> > > >                             <name>addDefaultConstructor</name>
> > > >                             <value>true</value>
> > > >                         </property>
> > > >                         <property>
> > > >                             <name>enforcePropertyRestrictions</name>
> > > >                             <value>true</value>
> > > >                         </property>
> > > >                     </toolProperties>
> > > >                 </configuration>
> > > >             </plugin>
> > > >
> > > >
> > > >
> > > > When I run mvn site:site to a txt file, I started looking through
> > the
> > > > trace and noticed:
> > > >
> > > > *[INFO] [cobertura:instrument]
> > > > [INFO] Cobertura 1.9 - GNU GPL License (NO WARRANTY) - See COPYRIGHT
> > > file
> > > > Cobertura: Loaded information on 13 classes.
> > > > Instrumenting 13 files to
> > > > C:\opt\temp\myproject\core\target\generated-classes\cobertura
> > > > Cobertura: Saved information on 13 classes.
> > > > Instrument time: 266ms
> > > >
> > > > [INFO] Instrumentation was successful.
> > > > *
> > > >
> > > >
> > > > So am I missing something with DBUnit plugin, or openJPA plugin as
> > to
> > > > point to *target\generated-classes\cobertura instead of
> > **target\classes
> > > > ???
> > > >
> > > >
> > > > *--
> > > > Thanks,
> > > > Mick Knutson
> > > >
> > > > http://www.baselogic.com
> > > > http://www.blincmagazine.com
> > > > http://www.linkedin.com/in/mickknutson
> > > > http://www.djmick.com
> > > > http://www.myspace.com/mickknutson
> > > > http://www.myspace.com/BLiNCMagazine
> > > > http://tahoe.baselogic.com
> > > > ---
> > >
> > >
> > >
> > >
> > > --
> > >  Thanks,
> > > Mick Knutson
> > >
> > > http://www.baselogic.com
> > > http://www.blincmagazine.com
> > > http://www.linkedin.com/in/mickknutson
> > > http://www.djmick.com
> > > http://www.myspace.com/mickknutson
> > > http://www.myspace.com/BLiNCMagazine
> > > http://tahoe.baselogic.com
> > > ---
> > >
> >
>
>
>
> --
> Thanks,
> Mick Knutson
>
> http://www.baselogic.com
> http://www.blincmagazine.com
> http://www.linkedin.com/in/mickknutson
> http://www.djmick.com
> http://www.myspace.com/mickknutson
> http://www.myspace.com/BLiNCMagazine
> http://tahoe.baselogic.com
> ---
>



-- 
Thanks,
Mick Knutson

http://www.baselogic.com
http://www.blincmagazine.com
http://www.linkedin.com/in/mickknutson
http://www.djmick.com
http://www.myspace.com/mickknutson
http://www.myspace.com/BLiNCMagazine
http://tahoe.baselogic.com
---

Re: [m2] cobertura code coverage for dbunit test classes with testNG and OpenJPA?

Posted by Mick Knutson <mi...@gmail.com>.
So I need to mention again, I am using the openJPA plugin to enhance the
byte code in this project.

But it seems strange. I uncommented <goal>check</goal> then got an error as
I am under 25% coverage (as expected), then commented it out again so the
site:site would complete. Then BAM! I got my coverage report.

Then I ran another clean install, and the report stopped again. So I
uncommented <goal>check</goal>, ran the build again that failed, commented
<goal>check</goal> again, and BAM it worked again.

I am not fully sure whate the trick is, but it seems I need to not clean the
build, and run the plugin with <goal>check</goal> in order to make this
work.

Has anyone run into this as well?

On Mon, Mar 24, 2008 at 4:20 AM, Erez Nahir <er...@gmail.com> wrote:

> Hi Mick,
>
> We have surefire 2.4.2 + testng + cobertura 2.2 works.
> Your cofiguration looks fine to me, but, I'm missing the cobertura
> definition in the <reporting> section.
> The only difference I see from out build (other then the need to add
> cobertuar to reporting section) is usage of ${basedir} as value. Try to
> remove it, I know surefire has some issues passing values of
> ${properties}.
>
> Here is what we have:
> In surefire plugin:
>                <property>
>                 <name>net.sourceforge.cobertura.datafile</name>
>                  <value>target/cobertura/cobertura.ser</value>
>               </property>
>             </systemProperties>
> In the reporting section:
>      <reporting>
>         <plugins>
> ...
> ...
>          <plugin>
>            <groupId>org.codehaus.mojo</groupId>
>             <artifactId>cobertura-maven-plugin</artifactId>
>            <version>2.2</version>
>           </plugin>
>        </plugins>
>      </reporting>
> HTH,
> Erez.
> On Sun, Mar 23, 2008 at 12:48 PM, Mick Knutson <mi...@gmail.com>
> wrote:
>
> > Anyone have any ideas?
> > I have tried cobertura 2.0 and 2.2 maven plugin and still the same
> result.
> >
> >
> > On Fri, Mar 21, 2008 at 2:36 PM, Mick Knutson <mi...@gmail.com>
> > wrote:
> >
> > > I have a Spring, OpenJPA, DBUnit, TestNG, HSQL build with Maven
> 2.0.8and
> > > there are 20 DAO tests that now pass. I am trying to now add cobertura
> > to
> > > this. I have used Cobertura extensively in the past, but never with
> > DBUnit.
> > >
> > > So, I am getting the report to generate, but everything is zero. So it
> > > appears that nothing was instrumented.
> > > Here is my surefire and cobertura plugins:
> > >
> > > <reporting>....
> > >             <plugin>
> > >                 <artifactId>maven-surefire-report-plugin</artifactId>
> > >                 <version>2.4.2</version>
> > >                 <configuration>
> > >                     <includes>
> > >                         <include implementation="java.lang.String
> > > ">**/*.java</include>
> > >                     </includes>
> > >                     <excludes>
> > >                         <exclude implementation="java.lang.String
> > > ">**/*Point*.java</exclude>
> > >                     </excludes>
> > >                     <systemProperties>
> > >                         <property>
> > >                             <name>net.sourceforge.cobertura.datafile
> > > </name>
> > >
> > > <value>${basedir}/target/cobertura/cobertura.ser</value>
> > >                         </property>
> > >                     </systemProperties>
> > >                     <argLine>-Xmx256m</argLine>
> > >                     <testFailureIgnore>true</testFailureIgnore>
> > >                 </configuration>
> > >             </plugin>
> > >
> > > <plugins>...
> > >
> > >
> > >             <plugin>
> > >                 <groupId>org.codehaus.mojo</groupId>
> > >                 <artifactId>dbunit-maven-plugin</artifactId>
> > >                 <version>1.0-beta-1</version>
> > >                 <configuration>
> > >                     <dataTypeFactoryName>${dbunit.dataTypeFactoryName
> > > }</dataTypeFactoryName>
> > >                     <driver>${jdbc.driverClassName}</driver>
> > >                     <username>${jdbc.username}</username>
> > >                     <password>${jdbc.password}</password>
> > >                     <url>${jdbc.url}</url>
> > >                     <src>src/test/resources/test-data.xml</src>
> > >                     <type>${dbunit.operation.type}</type>
> > >                     <schema>${dbunit.schema}</schema>
> > >                     <skip>${maven.test.skip}</skip>
> > >                 </configuration>
> > >                 <executions>
> > >                     <execution>
> > >                         <phase>test-compile</phase>
> > >                         <goals>
> > >                             <goal>operation</goal>
> > >                         </goals>
> > >                     </execution>
> > >                 </executions>
> > >                 <dependencies>
> > >                     <dependency>
> > >                         <groupId>${jdbc.groupId}</groupId>
> > >                         <artifactId>${jdbc.artifactId}</artifactId>
> > >                         <version>${jdbc.version}</version>
> > >                     </dependency>
> > >                 </dependencies>
> > >             </plugin>
> > >             <plugin>
> > >                 <groupId>org.codehaus.mojo</groupId>
> > >                 <artifactId>cobertura-maven-plugin</artifactId>
> > >                 <version>2.2</version>
> > >
> > >                 <configuration>
> > >                     <formats>
> > >                         <format>xml</format>
> > >                         <format>html</format>
> > >                     </formats>
> > >
> > >                     <instrumentation>
> > >                         <ignores>
> > >                             <ignore>org.apache.commons.logging.*
> > </ignore>
> > >                         </ignores>
> > >                         <excludes>
> > >                             <exclude>com/**/*Test.class</exclude>
> > >
> > >
> > <exclude>org/apache/log4j/**/*.class</exclude>
> > >
> > >                         </excludes>
> > >                     </instrumentation>
> > >                 </configuration>
> > >                 <executions>
> > >                     <execution>
> > >                         <goals>
> > >                             <goal>clean</goal>
> > >                         </goals>
> > >                     </execution>
> > >                 </executions>
> > >             </plugin>
> > >
> > >             <plugin>
> > >                 <groupId>org.codehaus.mojo</groupId>
> > >                 <artifactId>openjpa-maven-plugin</artifactId>
> > >                 <executions>
> > >                     <execution>
> > >                         <id>JPA Enhance</id>
> > >                         <phase>process-classes</phase>
> > >                         <goals>
> > >                             <goal>enhance</goal>
> > >                         </goals>
> > >                     </execution>
> > >                 </executions>
> > >                 <configuration>
> > >                     <toolProperties>
> > >                         <property>
> > >                             <name>addDefaultConstructor</name>
> > >                             <value>true</value>
> > >                         </property>
> > >                         <property>
> > >                             <name>enforcePropertyRestrictions</name>
> > >                             <value>true</value>
> > >                         </property>
> > >                     </toolProperties>
> > >                 </configuration>
> > >             </plugin>
> > >
> > >
> > >
> > > When I run mvn site:site to a txt file, I started looking through the
> > > trace and noticed:
> > >
> > > *[INFO] [cobertura:instrument]
> > > [INFO] Cobertura 1.9 - GNU GPL License (NO WARRANTY) - See COPYRIGHT
> > file
> > > Cobertura: Loaded information on 13 classes.
> > > Instrumenting 13 files to
> > > C:\opt\temp\myproject\core\target\generated-classes\cobertura
> > > Cobertura: Saved information on 13 classes.
> > > Instrument time: 266ms
> > >
> > > [INFO] Instrumentation was successful.
> > > *
> > >
> > >
> > > So am I missing something with DBUnit plugin, or openJPA plugin as to
> > > point to *target\generated-classes\cobertura instead of
> **target\classes
> > > ???
> > >
> > >
> > > *--
> > > Thanks,
> > > Mick Knutson
> > >
> > > http://www.baselogic.com
> > > http://www.blincmagazine.com
> > > http://www.linkedin.com/in/mickknutson
> > > http://www.djmick.com
> > > http://www.myspace.com/mickknutson
> > > http://www.myspace.com/BLiNCMagazine
> > > http://tahoe.baselogic.com
> > > ---
> >
> >
> >
> >
> > --
> >  Thanks,
> > Mick Knutson
> >
> > http://www.baselogic.com
> > http://www.blincmagazine.com
> > http://www.linkedin.com/in/mickknutson
> > http://www.djmick.com
> > http://www.myspace.com/mickknutson
> > http://www.myspace.com/BLiNCMagazine
> > http://tahoe.baselogic.com
> > ---
> >
>



-- 
Thanks,
Mick Knutson

http://www.baselogic.com
http://www.blincmagazine.com
http://www.linkedin.com/in/mickknutson
http://www.djmick.com
http://www.myspace.com/mickknutson
http://www.myspace.com/BLiNCMagazine
http://tahoe.baselogic.com
---

Re: [m2] cobertura code coverage for dbunit test classes with testNG and OpenJPA?

Posted by Erez Nahir <er...@gmail.com>.
Hi Mick,

We have surefire 2.4.2 + testng + cobertura 2.2 works.
Your cofiguration looks fine to me, but, I'm missing the cobertura
definition in the <reporting> section.
The only difference I see from out build (other then the need to add
cobertuar to reporting section) is usage of ${basedir} as value. Try to
remove it, I know surefire has some issues passing values of ${properties}.

Here is what we have:
In surefire plugin:
               <property>
                 <name>net.sourceforge.cobertura.datafile</name>
                 <value>target/cobertura/cobertura.ser</value>
               </property>
             </systemProperties>
In the reporting section:
      <reporting>
        <plugins>
...
...
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>cobertura-maven-plugin</artifactId>
            <version>2.2</version>
          </plugin>
        </plugins>
      </reporting>
HTH,
Erez.
On Sun, Mar 23, 2008 at 12:48 PM, Mick Knutson <mi...@gmail.com>
wrote:

> Anyone have any ideas?
> I have tried cobertura 2.0 and 2.2 maven plugin and still the same result.
>
>
> On Fri, Mar 21, 2008 at 2:36 PM, Mick Knutson <mi...@gmail.com>
> wrote:
>
> > I have a Spring, OpenJPA, DBUnit, TestNG, HSQL build with Maven 2.0.8and
> > there are 20 DAO tests that now pass. I am trying to now add cobertura
> to
> > this. I have used Cobertura extensively in the past, but never with
> DBUnit.
> >
> > So, I am getting the report to generate, but everything is zero. So it
> > appears that nothing was instrumented.
> > Here is my surefire and cobertura plugins:
> >
> > <reporting>....
> >             <plugin>
> >                 <artifactId>maven-surefire-report-plugin</artifactId>
> >                 <version>2.4.2</version>
> >                 <configuration>
> >                     <includes>
> >                         <include implementation="java.lang.String
> > ">**/*.java</include>
> >                     </includes>
> >                     <excludes>
> >                         <exclude implementation="java.lang.String
> > ">**/*Point*.java</exclude>
> >                     </excludes>
> >                     <systemProperties>
> >                         <property>
> >                             <name>net.sourceforge.cobertura.datafile
> > </name>
> >
> > <value>${basedir}/target/cobertura/cobertura.ser</value>
> >                         </property>
> >                     </systemProperties>
> >                     <argLine>-Xmx256m</argLine>
> >                     <testFailureIgnore>true</testFailureIgnore>
> >                 </configuration>
> >             </plugin>
> >
> > <plugins>...
> >
> >
> >             <plugin>
> >                 <groupId>org.codehaus.mojo</groupId>
> >                 <artifactId>dbunit-maven-plugin</artifactId>
> >                 <version>1.0-beta-1</version>
> >                 <configuration>
> >                     <dataTypeFactoryName>${dbunit.dataTypeFactoryName
> > }</dataTypeFactoryName>
> >                     <driver>${jdbc.driverClassName}</driver>
> >                     <username>${jdbc.username}</username>
> >                     <password>${jdbc.password}</password>
> >                     <url>${jdbc.url}</url>
> >                     <src>src/test/resources/test-data.xml</src>
> >                     <type>${dbunit.operation.type}</type>
> >                     <schema>${dbunit.schema}</schema>
> >                     <skip>${maven.test.skip}</skip>
> >                 </configuration>
> >                 <executions>
> >                     <execution>
> >                         <phase>test-compile</phase>
> >                         <goals>
> >                             <goal>operation</goal>
> >                         </goals>
> >                     </execution>
> >                 </executions>
> >                 <dependencies>
> >                     <dependency>
> >                         <groupId>${jdbc.groupId}</groupId>
> >                         <artifactId>${jdbc.artifactId}</artifactId>
> >                         <version>${jdbc.version}</version>
> >                     </dependency>
> >                 </dependencies>
> >             </plugin>
> >             <plugin>
> >                 <groupId>org.codehaus.mojo</groupId>
> >                 <artifactId>cobertura-maven-plugin</artifactId>
> >                 <version>2.2</version>
> >
> >                 <configuration>
> >                     <formats>
> >                         <format>xml</format>
> >                         <format>html</format>
> >                     </formats>
> >
> >                     <instrumentation>
> >                         <ignores>
> >                             <ignore>org.apache.commons.logging.*
> </ignore>
> >                         </ignores>
> >                         <excludes>
> >                             <exclude>com/**/*Test.class</exclude>
> >
> >
> <exclude>org/apache/log4j/**/*.class</exclude>
> >
> >                         </excludes>
> >                     </instrumentation>
> >                 </configuration>
> >                 <executions>
> >                     <execution>
> >                         <goals>
> >                             <goal>clean</goal>
> >                         </goals>
> >                     </execution>
> >                 </executions>
> >             </plugin>
> >
> >             <plugin>
> >                 <groupId>org.codehaus.mojo</groupId>
> >                 <artifactId>openjpa-maven-plugin</artifactId>
> >                 <executions>
> >                     <execution>
> >                         <id>JPA Enhance</id>
> >                         <phase>process-classes</phase>
> >                         <goals>
> >                             <goal>enhance</goal>
> >                         </goals>
> >                     </execution>
> >                 </executions>
> >                 <configuration>
> >                     <toolProperties>
> >                         <property>
> >                             <name>addDefaultConstructor</name>
> >                             <value>true</value>
> >                         </property>
> >                         <property>
> >                             <name>enforcePropertyRestrictions</name>
> >                             <value>true</value>
> >                         </property>
> >                     </toolProperties>
> >                 </configuration>
> >             </plugin>
> >
> >
> >
> > When I run mvn site:site to a txt file, I started looking through the
> > trace and noticed:
> >
> > *[INFO] [cobertura:instrument]
> > [INFO] Cobertura 1.9 - GNU GPL License (NO WARRANTY) - See COPYRIGHT
> file
> > Cobertura: Loaded information on 13 classes.
> > Instrumenting 13 files to
> > C:\opt\temp\myproject\core\target\generated-classes\cobertura
> > Cobertura: Saved information on 13 classes.
> > Instrument time: 266ms
> >
> > [INFO] Instrumentation was successful.
> > *
> >
> >
> > So am I missing something with DBUnit plugin, or openJPA plugin as to
> > point to *target\generated-classes\cobertura instead of **target\classes
> > ???
> >
> >
> > *--
> > Thanks,
> > Mick Knutson
> >
> > http://www.baselogic.com
> > http://www.blincmagazine.com
> > http://www.linkedin.com/in/mickknutson
> > http://www.djmick.com
> > http://www.myspace.com/mickknutson
> > http://www.myspace.com/BLiNCMagazine
> > http://tahoe.baselogic.com
> > ---
>
>
>
>
> --
>  Thanks,
> Mick Knutson
>
> http://www.baselogic.com
> http://www.blincmagazine.com
> http://www.linkedin.com/in/mickknutson
> http://www.djmick.com
> http://www.myspace.com/mickknutson
> http://www.myspace.com/BLiNCMagazine
> http://tahoe.baselogic.com
> ---
>

Re: [m2] cobertura code coverage for dbunit test classes with testNG and OpenJPA?

Posted by Mick Knutson <mi...@gmail.com>.
Anyone have any ideas?
I have tried cobertura 2.0 and 2.2 maven plugin and still the same result.


On Fri, Mar 21, 2008 at 2:36 PM, Mick Knutson <mi...@gmail.com> wrote:

> I have a Spring, OpenJPA, DBUnit, TestNG, HSQL build with Maven 2.0.8 and
> there are 20 DAO tests that now pass. I am trying to now add cobertura to
> this. I have used Cobertura extensively in the past, but never with DBUnit.
>
> So, I am getting the report to generate, but everything is zero. So it
> appears that nothing was instrumented.
> Here is my surefire and cobertura plugins:
>
> <reporting>....
>             <plugin>
>                 <artifactId>maven-surefire-report-plugin</artifactId>
>                 <version>2.4.2</version>
>                 <configuration>
>                     <includes>
>                         <include implementation="java.lang.String
> ">**/*.java</include>
>                     </includes>
>                     <excludes>
>                         <exclude implementation="java.lang.String
> ">**/*Point*.java</exclude>
>                     </excludes>
>                     <systemProperties>
>                         <property>
>                             <name>net.sourceforge.cobertura.datafile
> </name>
>
> <value>${basedir}/target/cobertura/cobertura.ser</value>
>                         </property>
>                     </systemProperties>
>                     <argLine>-Xmx256m</argLine>
>                     <testFailureIgnore>true</testFailureIgnore>
>                 </configuration>
>             </plugin>
>
> <plugins>...
>
>
>             <plugin>
>                 <groupId>org.codehaus.mojo</groupId>
>                 <artifactId>dbunit-maven-plugin</artifactId>
>                 <version>1.0-beta-1</version>
>                 <configuration>
>                     <dataTypeFactoryName>${dbunit.dataTypeFactoryName
> }</dataTypeFactoryName>
>                     <driver>${jdbc.driverClassName}</driver>
>                     <username>${jdbc.username}</username>
>                     <password>${jdbc.password}</password>
>                     <url>${jdbc.url}</url>
>                     <src>src/test/resources/test-data.xml</src>
>                     <type>${dbunit.operation.type}</type>
>                     <schema>${dbunit.schema}</schema>
>                     <skip>${maven.test.skip}</skip>
>                 </configuration>
>                 <executions>
>                     <execution>
>                         <phase>test-compile</phase>
>                         <goals>
>                             <goal>operation</goal>
>                         </goals>
>                     </execution>
>                 </executions>
>                 <dependencies>
>                     <dependency>
>                         <groupId>${jdbc.groupId}</groupId>
>                         <artifactId>${jdbc.artifactId}</artifactId>
>                         <version>${jdbc.version}</version>
>                     </dependency>
>                 </dependencies>
>             </plugin>
>             <plugin>
>                 <groupId>org.codehaus.mojo</groupId>
>                 <artifactId>cobertura-maven-plugin</artifactId>
>                 <version>2.2</version>
>
>                 <configuration>
>                     <formats>
>                         <format>xml</format>
>                         <format>html</format>
>                     </formats>
>
>                     <instrumentation>
>                         <ignores>
>                             <ignore>org.apache.commons.logging.*</ignore>
>                         </ignores>
>                         <excludes>
>                             <exclude>com/**/*Test.class</exclude>
>
>                             <exclude>org/apache/log4j/**/*.class</exclude>
>
>                         </excludes>
>                     </instrumentation>
>                 </configuration>
>                 <executions>
>                     <execution>
>                         <goals>
>                             <goal>clean</goal>
>                         </goals>
>                     </execution>
>                 </executions>
>             </plugin>
>
>             <plugin>
>                 <groupId>org.codehaus.mojo</groupId>
>                 <artifactId>openjpa-maven-plugin</artifactId>
>                 <executions>
>                     <execution>
>                         <id>JPA Enhance</id>
>                         <phase>process-classes</phase>
>                         <goals>
>                             <goal>enhance</goal>
>                         </goals>
>                     </execution>
>                 </executions>
>                 <configuration>
>                     <toolProperties>
>                         <property>
>                             <name>addDefaultConstructor</name>
>                             <value>true</value>
>                         </property>
>                         <property>
>                             <name>enforcePropertyRestrictions</name>
>                             <value>true</value>
>                         </property>
>                     </toolProperties>
>                 </configuration>
>             </plugin>
>
>
>
> When I run mvn site:site to a txt file, I started looking through the
> trace and noticed:
>
> *[INFO] [cobertura:instrument]
> [INFO] Cobertura 1.9 - GNU GPL License (NO WARRANTY) - See COPYRIGHT file
> Cobertura: Loaded information on 13 classes.
> Instrumenting 13 files to
> C:\opt\temp\myproject\core\target\generated-classes\cobertura
> Cobertura: Saved information on 13 classes.
> Instrument time: 266ms
>
> [INFO] Instrumentation was successful.
> *
>
>
> So am I missing something with DBUnit plugin, or openJPA plugin as to
> point to *target\generated-classes\cobertura instead of **target\classes
> ???
>
>
> *--
> Thanks,
> Mick Knutson
>
> http://www.baselogic.com
> http://www.blincmagazine.com
> http://www.linkedin.com/in/mickknutson
> http://www.djmick.com
> http://www.myspace.com/mickknutson
> http://www.myspace.com/BLiNCMagazine
> http://tahoe.baselogic.com
> ---




-- 
Thanks,
Mick Knutson

http://www.baselogic.com
http://www.blincmagazine.com
http://www.linkedin.com/in/mickknutson
http://www.djmick.com
http://www.myspace.com/mickknutson
http://www.myspace.com/BLiNCMagazine
http://tahoe.baselogic.com
---