Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-846

Cobertura plugin doesn't find source code in netbeans project structure

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Critical
    • Resolution: Fixed
    • cobertura-plugin
    • None
    • Platform: All, OS: All

    Description

      The cobertura plugin claims that it can't find the source code for a HTML
      report, but other parts of the report generation are working.

      Following project strucure and settings (with cobertura 1.9, hudson 1.142,
      cobertura plugin 0.8 ) (inspired by
      http://weblogs.java.net/blog/fabriziogiudici/archive/2006/11/setting_up_netb.html)

      Hudson configure:
      JavaApplication5/build/test/results/coverage.xml

      build.properties
      ================
      C:\Dokumente und Einstellungen\my_name\.netbeans\5.5.1\build.properties

      cobertura.home=D\:\\Programme\\Java
      cobertura-1.9
      cobertura.jar=${cobertura.home}/cobertura.jar
      cobertura.instrumented=/instrumented-classes

      project.properties
      ==================
      C:\Dokumente und
      Einstellungen\my_name\.hudson\jobs\JavaApplikation\workspace\JavaApplication5\nbproject\project.properties

      run.test.classpath=\
      ${cobertura.jar}:\
      ${build.dir}${cobertura.instrumented}:\
      ${javac.test.classpath}:\
      ${build.test.classes.dir}

      build.xml
      =========
      C:\Dokumente und
      Einstellungen\my_name\.hudson\jobs\JavaApplikation\workspace\JavaApplication5\build.xml
      <import file="nbproject/private/ci.xml" optional="true"/>

      <target name="-init-macrodef-junit">
      <echo>My junit was called! ${run.test.classpath}</echo>
      <!-<property file="${user.properties.file}"/>->

      <macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3">

      <attribute name="includes" default="**/*Test.java"/>
      <sequential>

      <junit showoutput="true" fork="true" dir="${basedir}"
      failureproperty="tests.failed" errorproperty="tests.failed">

      <batchtest todir="${build.test.results.dir}">
      <fileset dir="${test.src.dir}" includes="@

      {includes}

      "/>
      </batchtest>
      <classpath>
      <path path="${run.test.classpath}"/>
      </classpath>
      <syspropertyset>
      <propertyref prefix="test-sys-prop."/>
      <mapper type="glob" from="test-sys-prop." to=""/>
      </syspropertyset>
      <formatter type="brief" usefile="false"/>
      <formatter type="xml"/>
      <jvmarg line="${run.jvmargs}"/>
      </junit>
      </sequential>
      </macrodef>
      </target>

      ci.xml
      ======
      C:\Dokumente und
      Einstellungen\my_name\.hudson\jobs\JavaApplikation\workspace\JavaApplication5\nbproject\private\ci.xml
      <target name="cobertura-instrument" depends="init,compile-test,-pre-test-run">
      <property file="nbproject/project.properties" />
      <!-<property file="nbproject/private/ci.properties" />->
      <path id="cobertura.classpath">
      <fileset dir="${cobertura.home}">
      <include name="cobertura.jar" />
      <include name="lib/*/.jar" />
      </fileset>
      </path>
      <taskdef classpathref="cobertura.classpath" resource="tasks.properties"/>
      <cobertura-instrument todir="${build.dir}/instrumented-classes">
      <fileset dir="${build.classes.dir}">
      <include name="*/.class"/>
      </fileset>
      </cobertura-instrument>
      </target>

      <target name="test-coverage"

      depends="init,compile-test,-pre-test-run,cobertura-instrument,-do-test-run,test-report,-post-test-run,-test-browse"/>

      <target name="cobertura-coverage-report" depends="test-coverage">
      <property file="nbproject/project.properties"/>
      <!--<path id="cobertura.classpath">
      <fileset dir="${cobertura.home}">
      <include name="cobertura.jar" />
      <include name="lib/*/.jar" />
      </fileset>
      </path>-->
      <taskdef classpathref="cobertura.classpath" resource="tasks.properties" />
      <cobertura-report classpathref="cobertura.classpath" format="xml"
      srcdir="${src.dir}" destdir="${build.dir}/test/results" />
      <cobertura-report classpathref="cobertura.classpath" format="html"
      srcdir="${src.dir}" destdir="${build.dir}/test/results" /><!-- I've tested
      several settings here! -->
      <delete file="cobertura.ser" />
      <delete dir="${build.dir}/instrumented-classes" />
      </target>

      Project structure for hudson
      ============================
      C:\Dokumente und Einstellungen\my_name\.hudson
      jobs
      + JavaApplikation
      + builds
      + cobertura (tested with this location too)
      + javadoc
      + workspace
      + JavaApplication5
      + build
      + classes
      + test
      + classes
      + instrumented-classes
      + results (where I put the report initially)
      + dist
      + nbproject
      + private
      + src
      + test

      Attachments

        Activity

          jiai jiai created issue -

          Can you provide a sample cobertura.xml report file?

          This is most likely where the problem is.

          If you don't want to attach it here you can email it to:

          stephenconnolly at one dash dot com (that's one dash between the one and the dash)

          (i.e. the first "one" is spelled, then a dash symbol followed by a "dash"
          spelled followed by a dot symbol followed by com spelled)

          stephenconnolly Stephen Connolly added a comment - Can you provide a sample cobertura.xml report file? This is most likely where the problem is. If you don't want to attach it here you can email it to: stephenconnolly at one dash dot com (that's one dash between the one and the dash) (i.e. the first "one" is spelled, then a dash symbol followed by a "dash" spelled followed by a dot symbol followed by com spelled)

          I have a feeling this has to do with spaces in the paths... given that your
          hudson home is in C:\Dokumente und Einstellungen\

          If I can reproduce the issue on my system with spaces in the path then I should
          be able to fix it.

          I normally run hudson with either HUDSON_HOME=C:\hudson\ or
          HUDSON_HOME=C:\local\cvs\hudson\hudson\plugins\cobertura\work\

          And given the number of third party Java programs that have problems with spaces
          in the path, out of habbit, I normally avoid spaces in any paths that are used
          by Java.

          However, this plugin should work with spaces in the path, so I'll give it a
          bash on the head!

          stephenconnolly Stephen Connolly added a comment - I have a feeling this has to do with spaces in the paths... given that your hudson home is in C:\Dokumente und Einstellungen\ If I can reproduce the issue on my system with spaces in the path then I should be able to fix it. I normally run hudson with either HUDSON_HOME=C:\hudson\ or HUDSON_HOME=C:\local\cvs\hudson\hudson\plugins\cobertura\work\ And given the number of third party Java programs that have problems with spaces in the path, out of habbit, I normally avoid spaces in any paths that are used by Java. However, this plugin should work with spaces in the path, so I'll give it a bash on the head!
          stephenconnolly Stephen Connolly made changes -
          Field Original Value New Value
          Status Open [ 1 ] In Progress [ 3 ]

          Project structure for hudson
          ============================
          C:\Dokumente und Einstellungen\my_name\.hudson
          jobs
          + JavaApplikation
          + builds
          + cobertura (<-- when the plugin finds the source code, it puts the painted
          sources in here. You should not put anything in here.
          When you are looking at coverage results, if the build
          you are looking at is the last stable build (i.e. the
          most recent non-failure) the plugin will look in here
          for the painted source file. If the painted source
          file is present, then it will be displayed.
          If the painted source file is missing then it will say
          source file unavailable.

          For all older builds, it will always say "source file
          unavailable")
          + javadoc
          + workspace
          + JavaApplication5
          + build
          + classes
          + test
          + classes
          + instrumented-classes
          + results (<--You're fine putting the cobertura.xml report here)
          + dist
          + nbproject
          + private
          + src
          + test

          stephenconnolly Stephen Connolly added a comment - Project structure for hudson ============================ C:\Dokumente und Einstellungen\my_name\.hudson jobs + JavaApplikation + builds + cobertura (<-- when the plugin finds the source code, it puts the painted sources in here. You should not put anything in here. When you are looking at coverage results, if the build you are looking at is the last stable build (i.e. the most recent non-failure) the plugin will look in here for the painted source file. If the painted source file is present, then it will be displayed. If the painted source file is missing then it will say source file unavailable. For all older builds, it will always say "source file unavailable") + javadoc + workspace + JavaApplication5 + build + classes + test + classes + instrumented-classes + results (<--You're fine putting the cobertura.xml report here) + dist + nbproject + private + src + test
          jiai jiai added a comment -

          I'll attach the cobertura.xml tonight - I'm at work now and I'dont have access
          to my PC at home.

          Sure, I know there a lot of problems with spaces in the path. But there exisits
          a Microsoft world and they believe that file or directory names with spaces are
          OK and this directory (Documents and settings) is used by default.

          My installation was not planned as a productive CI server, it was a playing and
          learning experiment.

          jiai jiai added a comment - I'll attach the cobertura.xml tonight - I'm at work now and I'dont have access to my PC at home. Sure, I know there a lot of problems with spaces in the path. But there exisits a Microsoft world and they believe that file or directory names with spaces are OK and this directory (Documents and settings) is used by default. My installation was not planned as a productive CI server, it was a playing and learning experiment.
          jiai jiai added a comment -

          Content of coverage.xml
          =======================

          <?xml version="1.0"?>
          <!DOCTYPE coverage SYSTEM "http://cobertura.sourceforge.net/xml/coverage-03.dtd">

          <coverage line-rate="0.5454545454545454" branch-rate="0.5" version="1.9"
          timestamp="1190550797680">
          <sources>
          <source>src</source>
          </sources>
          <packages>
          <package name="de.jiai.demo" line-rate="0.4" branch-rate="0.5" complexity="0.0">
          <classes>
          <class name="de.jiai.demo.Main" filename="de/jiai/demo/Main.java"
          line-rate="0.4" branch-rate="0.5" complexity="0.0">
          <methods>
          <method name="<init>" signature="()V" line-rate="0.0" branch-rate="1.0">
          <lines>
          <line number="25" hits="0" branch="false"/>
          <line number="27" hits="0" branch="false"/>
          </lines>
          </method>
          <method name="main" signature="([Ljava/lang/String;)V"
          line-rate="0.8333333333333334" branch-rate="1.0">
          <lines>
          <line number="35" hits="1" branch="false"/>
          <line number="36" hits="1" branch="false"/>
          <line number="37" hits="1" branch="true" condition-coverage="100% (2/2)">
          <conditions>
          <condition number="0" type="jump" coverage="100%"/>
          </conditions>
          </line>
          <line number="38" hits="52" branch="false"/>
          <line number="41" hits="1" branch="false"/>
          <line number="44" hits="1" branch="false"/>
          <line number="46" hits="1" branch="false"/>
          <line number="49" hits="1" branch="false"/>
          <line number="50" hits="0" branch="false"/>
          <line number="51" hits="0" branch="false"/>
          <line number="52" hits="1" branch="false"/>
          <line number="53" hits="1" branch="false"/>
          </lines>
          </method>
          <method name="main2" signature="([Ljava/lang/String;)V" line-rate="0.0"
          branch-rate="0.0">
          <lines>
          <line number="61" hits="0" branch="false"/>
          <line number="62" hits="0" branch="false"/>
          <line number="63" hits="0" branch="true" condition-coverage="0% (0/2)">
          <conditions>
          <condition number="0" type="jump" coverage="0%"/>
          </conditions>
          </line>
          <line number="64" hits="0" branch="false"/>
          <line number="68" hits="0" branch="false"/>
          <line number="70" hits="0" branch="false"/>
          <line number="73" hits="0" branch="false"/>
          <line number="74" hits="0" branch="false"/>
          <line number="75" hits="0" branch="false"/>
          <line number="76" hits="0" branch="false"/>
          <line number="78" hits="0" branch="false"/>
          </lines>
          </method>
          </methods>
          <lines>
          <line number="25" hits="0" branch="false"/>
          <line number="27" hits="0" branch="false"/>
          <line number="35" hits="1" branch="false"/>
          <line number="36" hits="1" branch="false"/>
          <line number="37" hits="1" branch="true" condition-coverage="100% (2/2)">
          <conditions>
          <condition number="0" type="jump" coverage="100%"/>
          </conditions>
          </line>
          <line number="38" hits="52" branch="false"/>
          <line number="41" hits="1" branch="false"/>
          <line number="44" hits="1" branch="false"/>
          <line number="46" hits="1" branch="false"/>
          <line number="49" hits="1" branch="false"/>
          <line number="50" hits="0" branch="false"/>
          <line number="51" hits="0" branch="false"/>
          <line number="52" hits="1" branch="false"/>
          <line number="53" hits="1" branch="false"/>
          <line number="61" hits="0" branch="false"/>
          <line number="62" hits="0" branch="false"/>
          <line number="63" hits="0" branch="true" condition-coverage="0% (0/2)">
          <conditions>
          <condition number="0" type="jump" coverage="0%"/>
          </conditions>
          </line>
          <line number="64" hits="0" branch="false"/>
          <line number="68" hits="0" branch="false"/>
          <line number="70" hits="0" branch="false"/>
          <line number="73" hits="0" branch="false"/>
          <line number="74" hits="0" branch="false"/>
          <line number="75" hits="0" branch="false"/>
          <line number="76" hits="0" branch="false"/>
          <line number="78" hits="0" branch="false"/>
          </lines>
          </class>
          </classes>
          </package>
          <package name="de.jiai.demo.beans" line-rate="1.0" branch-rate="1.0"
          complexity="1.0">
          <classes>
          <class name="de.jiai.demo.beans.NewBean"
          filename="de/jiai/demo/beans/NewBean.java" line-rate="1.0" branch-rate="1.0"
          complexity="1.0">
          <methods>
          <method name="<init>" signature="()V" line-rate="1.0" branch-rate="1.0">
          <lines>
          <line number="23" hits="4" branch="false"/>
          <line number="25" hits="4" branch="false"/>
          </lines>
          </method>
          <method name="getName" signature="()Ljava/lang/String;" line-rate="1.0"
          branch-rate="1.0">
          <lines>
          <line number="37" hits="2" branch="false"/>
          </lines>
          </method>
          <method name="getValue" signature="()I" line-rate="1.0" branch-rate="1.0">
          <lines>
          <line number="58" hits="2" branch="false"/>
          </lines>
          </method>
          <method name="setName" signature="(Ljava/lang/String;)V" line-rate="1.0"
          branch-rate="1.0">
          <lines>
          <line number="45" hits="2" branch="false"/>
          <line number="46" hits="2" branch="false"/>
          </lines>
          </method>
          <method name="setValue" signature="(I)V" line-rate="1.0" branch-rate="1.0">
          <lines>
          <line number="66" hits="1" branch="false"/>
          <line number="67" hits="1" branch="false"/>
          </lines>
          </method>
          </methods>
          <lines>
          <line number="23" hits="4" branch="false"/>
          <line number="25" hits="4" branch="false"/>
          <line number="37" hits="2" branch="false"/>
          <line number="45" hits="2" branch="false"/>
          <line number="46" hits="2" branch="false"/>
          <line number="58" hits="2" branch="false"/>
          <line number="66" hits="1" branch="false"/>
          <line number="67" hits="1" branch="false"/>
          </lines>
          </class>
          </classes>
          </package>
          </packages>
          </coverage>

          jiai jiai added a comment - Content of coverage.xml ======================= <?xml version="1.0"?> <!DOCTYPE coverage SYSTEM "http://cobertura.sourceforge.net/xml/coverage-03.dtd"> <coverage line-rate="0.5454545454545454" branch-rate="0.5" version="1.9" timestamp="1190550797680"> <sources> <source>src</source> </sources> <packages> <package name="de.jiai.demo" line-rate="0.4" branch-rate="0.5" complexity="0.0"> <classes> <class name="de.jiai.demo.Main" filename="de/jiai/demo/Main.java" line-rate="0.4" branch-rate="0.5" complexity="0.0"> <methods> <method name="<init>" signature="()V" line-rate="0.0" branch-rate="1.0"> <lines> <line number="25" hits="0" branch="false"/> <line number="27" hits="0" branch="false"/> </lines> </method> <method name="main" signature="([Ljava/lang/String;)V" line-rate="0.8333333333333334" branch-rate="1.0"> <lines> <line number="35" hits="1" branch="false"/> <line number="36" hits="1" branch="false"/> <line number="37" hits="1" branch="true" condition-coverage="100% (2/2)"> <conditions> <condition number="0" type="jump" coverage="100%"/> </conditions> </line> <line number="38" hits="52" branch="false"/> <line number="41" hits="1" branch="false"/> <line number="44" hits="1" branch="false"/> <line number="46" hits="1" branch="false"/> <line number="49" hits="1" branch="false"/> <line number="50" hits="0" branch="false"/> <line number="51" hits="0" branch="false"/> <line number="52" hits="1" branch="false"/> <line number="53" hits="1" branch="false"/> </lines> </method> <method name="main2" signature="([Ljava/lang/String;)V" line-rate="0.0" branch-rate="0.0"> <lines> <line number="61" hits="0" branch="false"/> <line number="62" hits="0" branch="false"/> <line number="63" hits="0" branch="true" condition-coverage="0% (0/2)"> <conditions> <condition number="0" type="jump" coverage="0%"/> </conditions> </line> <line number="64" hits="0" branch="false"/> <line number="68" hits="0" branch="false"/> <line number="70" hits="0" branch="false"/> <line number="73" hits="0" branch="false"/> <line number="74" hits="0" branch="false"/> <line number="75" hits="0" branch="false"/> <line number="76" hits="0" branch="false"/> <line number="78" hits="0" branch="false"/> </lines> </method> </methods> <lines> <line number="25" hits="0" branch="false"/> <line number="27" hits="0" branch="false"/> <line number="35" hits="1" branch="false"/> <line number="36" hits="1" branch="false"/> <line number="37" hits="1" branch="true" condition-coverage="100% (2/2)"> <conditions> <condition number="0" type="jump" coverage="100%"/> </conditions> </line> <line number="38" hits="52" branch="false"/> <line number="41" hits="1" branch="false"/> <line number="44" hits="1" branch="false"/> <line number="46" hits="1" branch="false"/> <line number="49" hits="1" branch="false"/> <line number="50" hits="0" branch="false"/> <line number="51" hits="0" branch="false"/> <line number="52" hits="1" branch="false"/> <line number="53" hits="1" branch="false"/> <line number="61" hits="0" branch="false"/> <line number="62" hits="0" branch="false"/> <line number="63" hits="0" branch="true" condition-coverage="0% (0/2)"> <conditions> <condition number="0" type="jump" coverage="0%"/> </conditions> </line> <line number="64" hits="0" branch="false"/> <line number="68" hits="0" branch="false"/> <line number="70" hits="0" branch="false"/> <line number="73" hits="0" branch="false"/> <line number="74" hits="0" branch="false"/> <line number="75" hits="0" branch="false"/> <line number="76" hits="0" branch="false"/> <line number="78" hits="0" branch="false"/> </lines> </class> </classes> </package> <package name="de.jiai.demo.beans" line-rate="1.0" branch-rate="1.0" complexity="1.0"> <classes> <class name="de.jiai.demo.beans.NewBean" filename="de/jiai/demo/beans/NewBean.java" line-rate="1.0" branch-rate="1.0" complexity="1.0"> <methods> <method name="<init>" signature="()V" line-rate="1.0" branch-rate="1.0"> <lines> <line number="23" hits="4" branch="false"/> <line number="25" hits="4" branch="false"/> </lines> </method> <method name="getName" signature="()Ljava/lang/String;" line-rate="1.0" branch-rate="1.0"> <lines> <line number="37" hits="2" branch="false"/> </lines> </method> <method name="getValue" signature="()I" line-rate="1.0" branch-rate="1.0"> <lines> <line number="58" hits="2" branch="false"/> </lines> </method> <method name="setName" signature="(Ljava/lang/String;)V" line-rate="1.0" branch-rate="1.0"> <lines> <line number="45" hits="2" branch="false"/> <line number="46" hits="2" branch="false"/> </lines> </method> <method name="setValue" signature="(I)V" line-rate="1.0" branch-rate="1.0"> <lines> <line number="66" hits="1" branch="false"/> <line number="67" hits="1" branch="false"/> </lines> </method> </methods> <lines> <line number="23" hits="4" branch="false"/> <line number="25" hits="4" branch="false"/> <line number="37" hits="2" branch="false"/> <line number="45" hits="2" branch="false"/> <line number="46" hits="2" branch="false"/> <line number="58" hits="2" branch="false"/> <line number="66" hits="1" branch="false"/> <line number="67" hits="1" branch="false"/> </lines> </class> </classes> </package> </packages> </coverage>

          Should be fixed by 0.8.1
          (but please reopen if it's not)

          stephenconnolly Stephen Connolly added a comment - Should be fixed by 0.8.1 (but please reopen if it's not)
          stephenconnolly Stephen Connolly made changes -
          Resolution Fixed [ 1 ]
          Status In Progress [ 3 ] Resolved [ 5 ]
          jiai jiai added a comment -

          Unfortunately it doesn't seems to be fixed. There is no difference to the last
          but one version. I've sent you my sample project, perhaps this might help?

          jiai jiai added a comment - Unfortunately it doesn't seems to be fixed. There is no difference to the last but one version. I've sent you my sample project, perhaps this might help?
          jiai jiai made changes -
          Resolution Fixed [ 1 ]
          Status Resolved [ 5 ] Reopened [ 4 ]

          Should be fixed in 0.8.2 (I hope)

          stephenconnolly Stephen Connolly added a comment - Should be fixed in 0.8.2 (I hope)
          stephenconnolly Stephen Connolly made changes -
          Resolution Fixed [ 1 ]
          Status Reopened [ 4 ] Resolved [ 5 ]
          jiai jiai added a comment -

          Great - it works!

          jiai jiai added a comment - Great - it works!
          abayer Andrew Bayer made changes -
          Status Resolved [ 5 ] Closed [ 6 ]
          rtyler R. Tyler Croy made changes -
          Workflow JNJira [ 130919 ] JNJira + In-Review [ 200225 ]

          People

            stephenconnolly Stephen Connolly
            jiai jiai
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: