CodeCover Plugin

Skip to end of metadata
Go to start of metadata

Plugin Information

Plugin ID codecover Changes In Latest Release
Since Latest Release
Latest Release
Latest Release Date
Required Core
Nov 04, 2011
dashboard-view (version:2.1, optional)
maven-plugin (version:1.400)
Source Code
Issue Tracking
Open Issues
Kane Bonnette (id: kbonnette)
Usage Installations 2013-Apr 295
2013-May 301
2013-Jun 305
2013-Jul 326
2013-Aug 318
2013-Sep 329
2013-Oct 335
2013-Nov 324
2013-Dec 323
2014-Jan 351
2014-Feb 368
2014-Mar 374

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

Jenkins Configuration

1.- Enable recording CodeCover coverage report, and configure it.

Usage with ANT

1.- Make sure you include the CodeCover ant jars in your classpath, and the CodeCover taskdef:

<!-- Defines the CodeCover tasks -->
<taskdef name="codecover" classname="org.codecover.ant.CodecoverTask" classpath="${codecoverDir}/lib/codecover-ant.jar" />

2.- Then, the code you want to cover needs to be instrumented

<target name="instrument-sources" depends="clean">
    <instrument containerId="c" language="java" destination="${instrumentedSourceDir}" charset="utf-8" copyUninstrumented="yes">
      <source dir="${sourceDir}">
        <include name="**/*.java"/>
    <save containerId="c" filename="codecover.xml"/>

3.- If you need non-instrumented code (like your unit tests), move them to the instrumented folder so they are compiled together

<target name="collect">
  <copy todir="${instrumentedSourceDir}">
    <fileset dir="${test-dir}" />

4.- The instrumented code needs to be compiled

<target name="compile-instrumented" depends="instrument-sources">
  <javac srcdir="${instrumentedSourceDir}" destdir="${instrumentedSourceDir}" encoding="utf-8" target="1.5" debug="true" classpath="${codecoverDir}/lib/codecover-instrumentation-java.jar" includeAntRuntime="false"></javac>

5.- Run the compiled, instrumented code

<target name="run-instrumented" depends="compile-instrumented">
  <java classpath="${instrumentedSourceDir}:${codecoverDir}/lib/codecover-instrumentation-java.jar" fork="true" failonerror="true" classname="${mainClassName}">
    <jvmarg value="-Dorg.codecover.coverage-log-file=test.clf"/>

5a.- If you're using JUnit, the following method of running instrumented is used.

<target name="run-instrumented" depends="compile-instrumented">
  <junit printsummary="yes" fork="yes">
    <classpath refid="project.classpath" />
      <pathelement location="${codecoverDir}/lib/JUnit-TestRunner.jar" />
      <pathelement location="${codecoverDir}/lib/codecover-ant.jar" />
      <pathelement location="${codecoverDir}/lib/codecover-batch.jar" />
      <pathelement location="${codecoverDir}/lib/codecover-core.jar" />
      <pathelement path="${instrumentedSourceDir}" />
    <formatter type="xml" />
    <test name="${master-test-suite}" />
    <jvmarg value="-Dorg.codecover.coverage-log-file=test.clf" />

6.- Analyze the code.

<target name="create-report" depends="run-instrumented">
    <load containerId="c" filename="codecover.xml"/>
    <analyze containerId="c" coverageLog="test.clf" name="Test Session"/>
    <save containerId="c" filename="codecover.xml"/>
    <report containerId="c" destination="report.html" template="${codecoverDir}/report-templates/HTML_Report_hierarchic.xml">
        <testSession pattern=".*">
          <testCase pattern=".*"/>

Change Log

Version 1.0

  • Initial Release


plugin-report plugin-report Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.