Due to some maintenance issues, this service has been switched in read-only mode, you can find more information about the why

and how to migrate your plugin documentation in this blogpost

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 8 Current »

Plugin Information

View CodeCover on the plugin site for more information.

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
  • No labels