Cobertura Plugin

The current thinking is to merge this plugin into more generic coverage plugin. Help appreciated.

This plugin allows you to capture code coverage report from Cobertura. Hudson will generate the trend report of coverage.

The Cobertura plug in can be downloaded here.

Configuring the Cobertura Plugin

  1. Install the cobertura plugin (via Manage Hudson -> Manage Plugins)
  2. Configure your project's build script to generate cobertura XML reports (See below for examples with Ant and Maven2)
  3. Enable the "Publish Cobertura Coverage Report" publisher
  4. Specify the directory where the coverage.xml report is generated.
  5. (Optional) Configure the coverage metric targets to reflect your goals.

Configuring build tools

Here are the configuration details for common build tools. Please feel free to update this with corrections or additions. 

Maven 2

Single Project

If you are using a single module configuration, add the following into your pom.xml. This will cause cobertura to be called each time you run "mvn package".

<project ...>
    ...
    <build>
        ...
        <plugins>
            ...
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>cobertura-maven-plugin</artifactId>
                <version>2.2</version>
                <configuration>
                    <formats>
                        <format>xml</format>
                    </formats>
                </configuration>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>cobertura</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            ...
        </plugins>
        ...
    </build>
    ...
</project>



Execute cobertura only from hudson using profiles

You can reduce the load of your developer machine by using maven profiles to execute the plugin only if you are running within hudson. Theconfiguration below shows how to enable the plugin based on the information if maven was started by hudson.


<project ...>
    ...
    <profiles>
        <!-- Hudson by default defines a property BUILD_NUMBER which is used to enable the profile. -->
        <profile>
            <id>hudson</id>
            <activation>
                <property>
                    <name>BUILD_NUMBER</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>cobertura-maven-plugin</artifactId>
                        <version>2.2</version>
                        <configuration>
                            <formats>
                                <format>xml</format>
                            </formats>
                        </configuration>
                        <executions>
                            <execution>
                                <phase>package</phase>
                                <goals>
                                    <goal>cobertura</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
    ...
</project>

Project hierarchies

If you are using a common parent for all Maven2 modules you can move the plugin configuration to the pluginManagement section of the common parent...

<project ...>
    ...
    <build>
        ...
        <pluginManagement>
            <plugins>
                ...
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>cobertura-maven-plugin</artifactId>
                    <version>2.2</version>
                    <configuration>
                        <formats>
                            <format>xml</format>
                        </formats>
                    </configuration>
                    <executions>
                        <execution>
                            <phase>package</phase>
                            <goals>
                                <goal>cobertura</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                ...
            </plugins>
        </pluginManagement>
        ...
    </build>
    ...
</project>

 And add the plugin group and artifact to the children

<project ...>
    ...
    <build>
        ...
        <plugins>
            ...
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>cobertura-maven-plugin</artifactId>
            </plugin>
            ...
        </plugins>
        ...
    </build>
    ...
</project>

Execute cobertura only from hudson using profiles

It is highly recommend to reduce the workload of the developers machines by disabling the cobertura plugin and only using it from within hudson. The following excerpt from the parent shows how to do so:

<project ...>
    ...
    <profiles>
        <!-- Hudson by default defines a property BUILD_NUMBER which is used to enable the profile. -->
        <profile>
            <id>hudson</id>
            <activation>
                <property>
                    <name>BUILD_NUMBER</name>
                </property>
            </activation>
            <build>
                <pluginManagement>
                    <plugins>
                        <plugin>
                            <groupId>org.codehaus.mojo</groupId>
                            <artifactId>cobertura-maven-plugin</artifactId>
                            <version>2.2</version>
                            <configuration>
                                <formats>
                                    <format>xml</format>
                                </formats>
                            </configuration>
                            <executions>
                                <execution>
                                    <phase>package</phase>
                                    <goals>
                                        <goal>cobertura</goal>
                                    </goals>
                                </execution>
                            </executions>
                        </plugin>
                    </plugins>
                </pluginManagement>
            </build>
        </profile>
    </profiles>
    ...
</project>

 Now that your parent is only using the plugin management section if it is running from within hudson, you need the childern poms adapted as well:

<project ...>
    ...
    <!-- If we are running in hudson use cobertura. -->
    <profiles>
        <profile>
            <id>hudson</id>
            <activation>
                <property>
                    <name>BUILD_NUMBER</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>cobertura-maven-plugin</artifactId>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
    ...
</project>

Ant

You must first tell Ant about the Cobertura Ant tasks using a taskdef statement. The best place to do this is near the top of your build.xml script, before any target statements.

<property name="cobertura.dir" value="C:/javastuff/cobertura" />

<path id="cobertura.classpath">
    <fileset dir="${cobertura.dir}">
        <include name="cobertura.jar" />
        <include name="lib/**/*.jar" />
    </fileset>
</path>

<taskdef classpathref="cobertura.classpath" resource="tasks.properties" />

You'll need to instrument the classes that JUnit will be testing (not the test classes themselves) as such:

<cobertura-instrument todir="${instrumented.dir}">
    <ignore regex="org.apache.log4j.*" />
    <fileset dir="${classes.dir}">
        <include name="**/*.class" />
        <exclude name="**/*Test.class" />
    </fileset>
    <fileset dir="${guiclasses.dir}">
        <include name="**/*.class" />
        <exclude name="**/*Test.class" />
    </fileset>
    <fileset dir="${jars.dir}">
        <include name="my-simple-plugin.jar" />
    </fileset>
</cobertura-instrument>

Here's an example call to the JUnit ant task that has been modified to work with Cobertura. 

<junit fork="yes" dir="${basedir}" failureProperty="test.failed">
	<!--
		Specify the name of the coverage data file to use.
		The value specified below is the default.
	-->
	<sysproperty key="net.sourceforge.cobertura.datafile"
		file="${basedir}/cobertura.ser" />

	<!--
		Note the classpath order: instrumented classes are before the
		original (uninstrumented) classes.  This is important.
	-->
	<classpath location="${instrumented.dir}" />
	<classpath location="${classes.dir}" />

	<!--
		The instrumented classes reference classes used by the
		Cobertura runtime, so Cobertura and its dependencies
		must be on your classpath.
	-->
	<classpath refid="cobertura.classpath" />

	<formatter type="xml" />
	<test name="${testcase}" todir="${reports.xml.dir}" if="testcase" />
	<batchtest todir="${reports.xml.dir}" unless="testcase">
		<fileset dir="${src.dir}">
			<include name="**/*Test.java" />
		</fileset>
	</batchtest>
</junit>

Finally, you need a task to generate the xml report, where 'srcdir' is where the file cobertura.ser is generated to, and 'destdir' is where you want the report (coverage.xml) generated

<cobertura-report format="xml" destdir="${coveragereport.dir}" srcdir="${src.dir}" />



Version History

Version 0.8.8 (11/06/2009)

  • Revert the memory usage fixes in 0.8.7, since they were breaking source highlighting (issue #3597)

Version 0.8.7 (04/06/2009)

  • Improved help and error messages to attempt to avoid "Can not find coverage-results" (issue #1423)
  • Fixed "Consider only stable builds" setting (issue #3475)
  • Improved memory usage when drawing trend graphs (issue #3597)

Version 0.8.6 (07/05/2009)

  • The plugin runs before notifications are sent out, to avoid inconsistency in build status reporting (issue #1285)
  • The cobertura statistics graphic on a project window isn't rendered (issue #2851)

Version 0.8.4 (21/10/2007)

  • ???

Version 0.8.3 (12/10/2007)

Version 0.8.2 (4/10/2007)

Version 0.8.1 (28/09/2007)

  • Fixes issues running under JDK 1.5
  • Fixes some issues with finding source code

Version 0.8 (20/09/2007)

  • Works with JDK 5 as well as JDK 6 (removing JDK dependency introduced during regression fixing)

Version 0.7 (20/09/2007)

  • Better fix of regressions introduced in 0.5

Version 0.6 (20/09/2007)

  • Fix of regressions introduced in 0.5 

Version 0.5 (20/09/2007)

  • Now with built in source code painting! (Source code is available at the file level for the latest stable build only).

Note that the conditional coverage is the highest coverage from all the cobertura reports aggregated in  each build.  Thus if you have two reports and one covers only 50% of a conditional and the other covers a different 25%, conditional coverage will be reported as 50% and not the 75% that you could argue it should be!

  • The trend graph now works when there are broken builds in the build history.

Version 0.4 (29/08/2007)

  • Initial support for multi-report aggregation (may get totals incorrect if reports overlap for individual classes - I'll need to get source file painting support implemented to remove that issue.  However, this is just how the files are parsed.  This version will archive the files correctly so when it is fixed your history should report correctly)

Version 0.3 (28/08/2007)

  • Fixed NPE parsing some cobertura reports generated by Cobertura version 1.8.
  • Project level report should now work (except possibly when a build is in progress) 

Version 0.2 (28/08/2007)

  • Fixed problem with configuration (was not persisting configuration details)
  • Changed health reporting configuration (now handles the more generic code)
  • Tidy-up of reports
  • Known issues:
    • Project level report does not work in all cases
    • Class and Method level reports should display source code with coverage if source code is available (in workspace) 

Version 0.1 (27/08/2007)

  • Initial release.  Only parses xml report. Some rough edges in the UI. 

Labels

  Edit Labels
  1. Sep 02, 2007

    Anonymous says:

    After some hours, I got it to work with the Netbeans makefile. :) The handling o...

    After some hours, I got it to work with the Netbeans makefile.

    The handling of build.properties and project.properties was a bit tricky for me as a novice Ant user, because I don't wanted to "pollute" the other workstations in our working group with dependencies to cobertura. Besides, there seems to be a bug with the datafile attribute, which should define the position of cobertura.ser, but in fact this attribute doesn't work correctly.

    I was a bit dissapointed about the graphical representation of the Cobertura report in the Hudson plugin, knowing the HTML report of Cobertura. Isn't there a possibility to let Cobertura produce the HTML report and put a link to it in Hudson?

    But alltogether I became an entusiastic user of Hudson in the last four days! It's really an excellent tool.

    1. Sep 20, 2007

      Stephen Connolly says:

      Could you please add a section into this page detailing how to get this plugin w...

      Could you please add a section into this page detailing how to get this plugin working with the Netbeans makefile?

      1. Sep 23, 2007

        Jessica-Aileen says:

        There is no magic with it. I've simply used the advices from this blog:

        There is no magic with it. I've simply used the advices from this blog: http://weblogs.java.net/blog/fabriziogiudici/archive/2006/11/setting_up_netb.html

        If I have more time I'll post my configuration for findbugs, violations (pmd, findbugs, cpd, checkstyle) and cobertura. But it shouldn't be a problem with Fabrizios blog entry to make a suitable buildfile.

  2. Sep 02, 2007

    Anonymous says:

    I agree with the previous poster \\ the HTML reports generated by Cobertura are ...

    I agree with the previous poster -- the HTML reports generated by Cobertura are great.  My ANT file already generates those -- so what I want (in addition to the timeline graph) is to put a link to the coverage reports in my build status page.  That has to be easy, right?

  3. Sep 14, 2007

    Anonymous says:

    \1 for integrating the plain Cobertura reports in some way or another. The plugi...

    +1 for integrating the plain Cobertura reports in some way or another.

    The plugin is great by the way  

  4. Sep 19, 2007

    Stephen Connolly says:

    The issue with integrating the plain Cobertura reports is that this plugin is ag...

    The issue with integrating the plain Cobertura reports is that this plugin is aggregating multiple cobertura reports, so I have to generate the HTML report by hand.  The code for this is getting close to ready, but I was on holidays and have a backlog in work before I can get to it.

    1. Sep 20, 2007

      Stephen Connolly says:

      See Version 0.5 which was released today

      See Version 0.5 which was released today

      1. Sep 21, 2007

        Anonymous says:

        The HTML coverage report is produced now :) \ but there is a problem: The plugin...

        The HTML coverage report is produced now - but there is a problem: The plugin doesn't include it! It seems to be that the plugin ist awaiting the HTML report in a "hard wired" directory named "cobertura" in the jobname-directory under jobs.

        There should be a possibility to tell the plugin where the destination directory is - in the same way that you define the "Cobertura xml report pattern" in the project configuration.

        At the moment I can't find out how to tell cobertura to use the hard-wired directory - but it is nearly midnight now.

        1. Sep 21, 2007

          Anonymous says:

          It makes no difference if the report is in the cobertura directory or elsewhere:...

          It makes no difference if the report is in the cobertura directory or elsewhere: The plugin claims "Source code is unavailable". Two minutes past midnight now ...

          1. Sep 22, 2007

            Stephen Connolly says:

            The source code will only be available for the most recent build.&nbsp; Disk spa...

            The source code will only be available for the most recent build.  Disk space is cheap, but not cheap enough to save it for every build.  Also, there is not much use in knowing the past source code coverage (and there is the method level coverage for such anyway)

            If you are not seeing the source code for the most recent build, please file an issue and I'll have a look.

            1. Sep 22, 2007

              Anonymous says:

              Perhaps I misunderstood what you meant the report is produced and I can access i...

              Perhaps I misunderstood what you meant - the report is produced and I can access it via the workspace hierarchy in hudson. But there is no link in the report itself. Where I assume it should be, in the detailed report generated by the plugin, there is only the text "Source code is unavailable".

              Where can I file the issue - in the hudson issue tracker?

              1. Sep 23, 2007

                Stephen Connolly says:

                Yes the issue tracker is the best place for it. The basic idea is that the plugi...

                Yes the issue tracker is the best place for it.

                The basic idea is that the plugin goes looking for the source code in all the places that cobertura says it could have been.  If it did not find the source code then you won't see it.

                what version of cobertura are you using (most of my testing is with 1.9)

                1. Sep 23, 2007

                  Jessica-Aileen says:

                  I've filed it as https://hudson.dev.java.net/issues/showbug.cgi?id=846
  5. Oct 11, 2007

    Anonymous says:

    The plugin does not work. I have Cobertura successfully generating both HTML and...

    The plugin does not work. I have Cobertura successfully generating both HTML and XML reports as part of the build. I have the XML pattern set in the plugin configuration and it's able to find it successfully. But that's where the magic stops.

     Here is the output from the log:Recording test results
    Publishing Cobertura coverage report...
    Publishing Cobertura coverage results...
    FATAL: /local/bamboo/.hudson/jobs/MYJOB/cobertura/com/foo/dec/framework/dataAccessServices (Is a directory)
    java.io.FileNotFoundException: /local/bamboo/.hudson/jobs/MYJOB/cobertura/com/foo/dec/framework/dataAccessServices (Is a directory)
    at java.io.FileOutputStream.open(Native Method)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:179)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:131)
    at hudson.FilePath.write(FilePath.java:600)
    at hudson.plugins.cobertura.renderers.SourceCodePainter.paintSourceCode(SourceCodePainter.java:48)
    at hudson.plugins.cobertura.renderers.SourceCodePainter.invoke(SourceCodePainter.java:127)
    at hudson.plugins.cobertura.renderers.SourceCodePainter.invoke(SourceCodePainter.java:28)
    at hudson.FilePath.act(FilePath.java:280)
    at hudson.plugins.cobertura.CoberturaPublisher.perform(CoberturaPublisher.java:250)
    at hudson.model.Build$RunnerImpl.post2(Build.java:138)
    at hudson.model.AbstractBuild$AbstractRunner.post(AbstractBuild.java:244)
    at hudson.model.Run.run(Run.java:597)
    at hudson.model.Build.run(Build.java:103)
    at hudson.model.ResourceController.execute(ResourceController.java:66)
    at hudson.model.Executor.run(Executor.java:62)

    1. Oct 21, 2007

      Anonymous says:

      Have you filed an issue with respect to this? The best way to get attention is t...

      Have you filed an issue with respect to this?

      The best way to get attention is to file an issue or post on the mailing list.

  6. Oct 24, 2007

    Anonymous says:

    Recenty, I am getting the following error when displayng the graph@:\\ Status C...

    Recenty, I am getting the following error when displayng the graph@:

    Status Code: 500

    Exception:
    Stacktrace: java.lang.LinkageError: hudson/util/ChartUtil
    at hudson.plugins.cobertura.targets.CoverageResult.doGraph(CoverageResult.java:298)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.kohsuke.stapler.Function$InstanceFunction.invoke(Function.java:103)
    at org.kohsuke.stapler.Function.bindAndinvoke(Function.java:59)
    at org.kohsuke.stapler.MetaClass$1.doDispatch(MetaClass.java:63)
    at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:30)
    at org.kohsuke.stapler.Stapler.invoke(Stapler.java:294)
    at org.kohsuke.stapler.MetaClass$15.dispatch(MetaClass.java:361)
    at org.kohsuke.stapler.Stapler.invoke(Stapler.java:294)
    at org.kohsuke.stapler.MetaClass$7.doDispatch(MetaClass.java:208)
    at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:30)
    at org.kohsuke.stapler.Stapler.invoke(Stapler.java:294)
    at org.kohsuke.stapler.MetaClass$9.doDispatch(MetaClass.java:240)
    at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:30)
    at org.kohsuke.stapler.Stapler.invoke(Stapler.java:294)
    at org.kohsuke.stapler.Stapler.invoke(Stapler.java:231)
    at org.kohsuke.stapler.Stapler.service(Stapler.java:79)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:45)
    at winstone.ServletConfiguration.execute(ServletConfiguration.java:249)
    at winstone.RequestDispatcher.forward(RequestDispatcher.java:335)
    at winstone.RequestDispatcher.doFilter(RequestDispatcher.java:378)
    at hudson.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:79)
    at winstone.FilterConfiguration.execute(FilterConfiguration.java:195)
    at winstone.RequestDispatcher.doFilter(RequestDispatcher.java:368)
    at winstone.RequestDispatcher.forward(RequestDispatcher.java:333)
    at winstone.RequestHandlerThread.processRequest(RequestHandlerThread.java:244)
    at winstone.RequestHandlerThread.run(RequestHandlerThread.java:150)
    at java.lang.Thread.run(Unknown Source)
    Any  ideas what maybe wrong?

    1. Oct 24, 2007

      Anonymous says:

      {}PRETTY PLEASE WITH CATNIP ON TOP\! File an issue https://hudson.dev.java.net/s...

      PRETTY PLEASE WITH CATNIP ON TOP!

      File an issue

      Or at least post your question on the mailing list

      Nobody is watching this comments section

  7. Oct 31, 2007

    Anonymous says:

    The instructions above say that examples for maven and ant are below. I don't se...

    The instructions above say that examples for maven and ant are below. I don't see any such examples. Maybe they could be more attention-getting. thanks.

    1. Nov 02, 2007

      Anonymous says:

      i second that.

      i second that.

      1. Nov 16, 2007

        Stephen Connolly says:

        {}MORE PRETTY PLEASE WITH EXTRA CATNIP ON TOP\! This is a Wiki.&nbsp; If you spo...

        MORE PRETTY PLEASE WITH EXTRA CATNIP ON TOP!

        This is a Wiki.  If you spot something that is incorrect, please correct it.  If you spot something that is missing, please add it.  If you spot something that should be there but is not, please add a placeholder. 

        1. Mar 27, 2008

          Mike Haller says:

          Stephen, i tried to query the issue tracker but no luck. The dev.java.net issue ...

          Stephen, i tried to query the issue tracker but no luck. The dev.java.net issue tracker is very unusable. Userfriendlyness equals zero.

          According to the current version of SourceCodePainter in source control, there have already been changes. Do you know the cause of the FileNotFound Exception or how to circumvent this issue?

  8. Dec 12, 2007

    Mike Caron says:

    Just started using this. Really cool work, but it seems like the HTML reports ge...

    Just started using this. Really cool work, but it seems like the HTML reports gen'd by the plugin always report 100%, even though the weather is accurate and the file view reports correct red and green lines. I became an observer so that I could grab the code and work on it. I also like the idea of linking the "Coverage Report" to the original HTML reports, so I was going to do that too. Of course, I'd provide patches. But I first need code access...

  9. Jun 02, 2008

    fabrice says:

    I use&nbsp;Hudson ver. 1.219 and I verified my cobertura config matches this on ...

    I use Hudson ver. 1.219 and I verified my cobertura config matches this on this webpage, HTML and XML files are generated in target/site/cobertura but there is no image generated on the job page, no link which allow me to see cobertura reports and trends.

     I think it is a bug.

  10. Jun 03, 2008

    Jose Muanis says:

    Just updated hudson to 1.220, cobertura plugin version 0.8.4 Build ok, coverage....

    Just updated hudson to 1.220, cobertura plugin version 0.8.4

    Build ok, coverage.xml being generated just as expected in this tutorial. but I get no image nor link on the status page.

    No kind of errors in the log file.

     Any ideas where I can find information to help finding this bug?

    1. Jun 04, 2008

      fabrice says:

      ouf I am not alone on this new problem :) help us :)

      ouf I am not alone on this new problem

      help us

      1. Jun 04, 2008

        Jose Muanis says:

        Fabrice, &nbsp;I've checked out version 0.8.5SNAPSHOT and its working. &nbsp;But...

        Fabrice,

         I've checked out version 0.8.5-SNAPSHOT and its working.

         But anyway, the coverage reports only apper at module page

        1. Jun 05, 2008

          fabrice says:

          Ok nice It would be nice too if we have a new stable release. When ?

          Ok nice

          It would be nice too if we have a new stable release. When ?

    2. Apr 01

      Natalie Vaslavsky says:

      Jose,\\ I have the same problem " Build ok, coverage.xml being generated just a...

      Jose,

      I have the same problem "

      Build ok, coverage.xml being generated just as expected in this tutorial. but I get no image nor link on the status page."

      I use cobertura plugin version 0.8.4.

      Have you bee able to solve?

  11. Jun 18, 2008

    truong van nga says:

    Hi, have you some news about a stable release of this plugin? I can only downloa...

    Hi, have you some news about a stable release of this plugin?

    I can only download the  0.8.4 which is not working
    the report don't appear on the web site (but my coverage.xml are generated)

    Is the   0.8.5-SNAPSHOT always available? and where?

  12. Jun 26, 2008

    Nicolas Ruffel says:

    Hi, I have the same issue plus another one. I have a main project with lots of s...

    Hi, I have the same issue plus another one.

    I have a main project with lots of sub-projects. I configured only one job for the main project (using maven2) and it calls allthe sub modules. Great. But I want the cobertura reports generated without running the tests twice.

    If I call the goal "install", cobertura is not run. If I run "cobertura:cobertura", some modules  are tested with some old dependencies since some new packages haven't been "installed" in the repository. "install cobertura:cobertura" works, but it runs tests twice.

    What am I doing wrong?

    Thanks for your hints

    1. Sep 17, 2008

      Ramil Israfilov says:

      Hi, in order to execute cobertura during test phase just add following in your r...

      Hi,
      in order to execute cobertura during test phase just add following in your root pom.xml file

      <groupId>org.codehaus.mojo</groupId>
                      <artifactId>cobertura-maven-plugin</artifactId>
                      <version>2.2</version>
                      <executions>
                          <execution>
                              <phase>test</phase>
                              <goals>
                                  <goal>cobertura</goal>
                              </goals>
                          </execution>
                      </executions>
                    </groupId>

      After that cobertura task will be executed during test phase.
      But how to avoid execution of tests twice I don't know.

  13. Dec 02, 2008

    John Allen says:

    Is there any plans to make this work with the builtin maven 2 project type? doh,...

    Is there any plans to make this work with the built-in maven 2 project type? doh, its already there! its just that i'm running a custom cobertura mojo called report-only and that was being detected by the hudson cobertura plugin. reports don't seem aggregated though...

  14. Jan 08

    Dmitry Kudryavtsev says:

    Hello. I've discovered that plugin doesn't work correctly if your build is unsta...

    Hello.

    I've discovered that plugin doesn't work correctly if your build is unstable. For example if some of your unit tests failed then you got "Source code is unavailable" message although all reports are gathered and you can see coverage rate. Global link to cobertura report also would be broken or invalid because you may not have any live stable build  or you last stable build is not actual

    So I looked into code and noticed that method isSourceFileAvailable in CoverageResult.class looks like "... owner == owner.getProject().getLastStableBuild() && blah-blah-blah ...".

    I think this is not really good, because in TDD you always have some errors in tests, so you would never see source code.

    Maybe it is better to change code of isSourceFileAvailable to something like "...getProject().getLastSuccessfulBuild()..." and also fix urls that is generated by CoberturaProjectAction.class ?

    I would like to contribute patch but I'm not sure how to do it.

    And sorry for my bad English  - it is not my native language.

  15. Mar 11

    witek says:

    There is a way to avoid doubled testing. We have added new "generatereport" goal...

    There is a way to avoid doubled testing. We have added new "generate-report" goal to cobertura-maven-plugin, so you can instrument code before tests and generate xml report when tests (or integration-tests) phase is finished. See top.touk.pl

    1. Apr 16

      Brian Lalor says:

      Have you released this modified plugin? I'm not able to find any more informatio...

      Have you released this modified plugin? I'm not able to find any more information on top.touk.pl than what's in your blog post there.

  16. Apr 02

    Daniel Rudman says:

    Hi, I am using Maven2/SVN and the latest Hudson Cobertura plugin 0.8.5. I have t...

    Hi,
    I am using Maven2/SVN and the latest Hudson Cobertura plugin 0.8.5. I have the coverage report generated and all the settings set correctly, but I do not see the coverage report in Hudson either in the job or module pages. No errors in the log either. Any ideas of how else I can debug? Pretty much stuck.

    Thanks!

    1. Apr 09

      Natalie Vaslavsky says:

      What version of Hudson can be used with cobertura plugin 0.8.5. I have 1.226. I ...

      What version of Hudson can be used with cobertura plugin 0.8.5.

      I have 1.226.

      I have a hudson error while configuring a project.

      Thanks

  17. May 14

    Joaquin Morcate says:

    Hi, I'm using&nbsp; Hudson 1.304 and Cobertura plugin 0.8.6. In my build.xml fil...

    Hi,

    I'm using  Hudson 1.304 and Cobertura plugin 0.8.6. In my build.xml file I have the following that works fine when I build from the command line but it keeps on complaining about the task definition when is build by hudson. Any idea? Thank you.

        <property name="cobertura.dir" location="/usr/share/tools/cobertura-1.9.1" />
        <path id="cobertura.classpath">
            <fileset dir="${cobertura.dir}">
                <include name="cobertura.jar" />
                <include name="lib/**/*.jar" />
            </fileset>
        </path>
        <taskdef classpathref="cobertura.classpath" resource="tasks.properties" />