1. says:

    December 7, 2010 at 10:29 PM

    Its good documentation, however i fail to understand how dataFile works.
    Does cobertura creates it or testng task creates it.
    I got the report but the coverage is 0. Can’t figure out how to get the coverage.
    My tests shows proper coverage using the eclipse plugin.
    Please help

    • says:

      December 7, 2010 at 11:04 PM

      The cobertura.ser data file is created by Cobertura and not by TestNG, it contains the instrumentation data about your tests as they are run. A coverage of 0 in the reports usually means the classpath is not configured correctly (i.e., cobertura cannot find the instrumented classes). Make sure you define the source (test classes) classpath and the target (source classes) correctly.

  2. says:

    December 9, 2010 at 10:19 PM

    still can’t figure out. Can you help me please
    One thing more to know. Another ant script runs first and places my source compiled jar file to /testlib.

  3. says:

    December 11, 2010 at 3:44 AM

    Sumit, a quick read through your code reveals some configuration issues, you are not defining the coverageDataFile correctly:

    Add the following to your configuration:

     <property key="cb.file" value="${basedir}/cobertura.ser" />  

    Change the net.sourceforge.cobertura.datafile property to:

     <sysproperty key="net.sourceforge.cobertura.datafile" file="${cb.file}" />  

    Change the “clean” target to:

    <delete file="${cb.file}" />  

    Change the “cb.instrument” target to:

    <cobertura-instrument todir="${cb.instrument.dir}/"  

    Do the same for the datafile attribute in your cb.xml and cb.html targets.

    I suspect cobertura instruments the code but cannot find the instrumentation file which why your getting 0 coverage.

Leave a Reply

Your email address will not be published. Required fields are marked *