Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8652275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T14:16:20+00:00 2026-06-12T14:16:20+00:00

I have a question about cobertura in a connection with Ant scripts. I have

  • 0

I have a question about cobertura in a connection with Ant scripts. I have already read these two articles on StackOverflow:
SONAR – Measure Code Coverage using Cobertura and Bamboo + sonar.dynamicAnalysis=reuseReports = 0% Rules Compliance

Furthermore, I have searched in the internet for a solution for my problem.
Now I hope you can help me.

The initial situation:
I have an Ant script to compile a library and then a test target. Now I have added cobertura. After some time I got it out that the classes and also the ser file is stored. The report is also generated, but with no coverage.
But now the problem is that the JUnit test will not work. The following error message can be found in the xml:

<testcase classname="com.***.***.***.***.***Test" name="test16" time="0.0">
<error message="com/***/***/***/***/***Rule" type="java.lang.NoClassDefFoundError">java.lang.NoClassDefFoundError: com/***/***/***/***/***Rule
at com.***.***.***.***.***Test.setUp(Unknown Source)
at org.eclipse.ant.internal.launching.remote.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32)
at org.eclipse.ant.internal.launching.remote.InternalAntRunner.run(InternalAntRunner.java:424)
at org.eclipse.ant.internal.launching.remote.InternalAntRunner.main(InternalAntRunner.java:138)

I currently use the following code in the Ant script:

<project name="MainLIB" default="vbuild" basedir="./">
<path id="path.additionaltasks">
    <fileset dir="../BUILD/antlib">
        <include name="cobertura.jar" />
        <include name="log4j-1.2.9.jar" />
        <include name="asm-3.0.jar" />
        <include name="asm-tree-3.0.jar" />
        <include name="jakarta-oro-2.0.8.jar" />
    </fileset>
</path>
<taskdef resource="tasks.properties" classpathref="path.additionaltasks" />

<path id="path.LIB">
    <fileset dir="lib" includes="**/**.jar" />
</path>

<path id="path.UNITTEST">
    <path refid="path.LIB" />
    <pathelement path="build/cobertura/classes" />
    <pathelement path="build/classes" />
    <pathelement path="build/test-classes" />
</path>

<property name="dir.build" value="build" />
<property name="dir.build.classes" value="${dir.build}/classes" />
<property name="dir.build.cobertura" value="${dir.build}/cobertura" />
<property name="dir.build.cobertura.classes" value="${dir.build.cobertura}/classes" />
<property name="dir.build.test.classes" value="${dir.build}/test-classes" />
<property name="dir.build.test.report" value="${dir.build}/test-reports" />
<property name="dir.build.dist" value="${dir.build}/dist" />

<target name="vbuild" depends="build,test" description="Build and run tests" />

<target name="build" description="Compile classes and create .jar file in build/dist">

    <delete dir="${dir.build}" />
    <mkdir dir="${dir.build.classes}" />

    <javac srcdir="src" classpathref="path.LIB" verbose="false" destdir="${dir.build.classes}" includeantruntime="false" includejavaruntime="false" debug="true">
    </javac>

    <mkdir dir="${dir.build.dist}" />

    <jar jarfile="${dir.build.dist}/${jar.name}.jar" basedir="${dir.build.classes}">
    </jar>
</target>

<target name="test" description="Compile and Run jUnit Tests">

    <mkdir dir="${dir.build.test.classes}" />
    <mkdir dir="${dir.build.test.report}" />

    <javac srcdir="test" classpathref="path.UNITTEST" verbose="false" destdir="${dir.build.test.classes}" includeantruntime="false" includejavaruntime="false">
    </javac>

    <delete dir="${dir.build.cobertura}" />
    <mkdir dir="${dir.build.cobertura}" />
    <mkdir dir="${dir.build.cobertura.classes}" />
    <cobertura-instrument todir="${dir.build.cobertura.classes}" datafile="${dir.build.cobertura}/cobertura.ser">
        <fileset dir="${dir.build.classes}" />

    </cobertura-instrument>

    <junit printsummary="yes">
        <classpath>
            <!--<pathelement path="build/cobertura/classes" />-->
            <path refid="path.UNITTEST" />

        </classpath>
        <formatter type="xml" />

        <batchtest todir="${dir.build.test.report}">
            <fileset dir="${dir.build.test.classes}">
                <include name="**/*Test.class" />
            </fileset>
        </batchtest>
    </junit>

    <cobertura-report format="xml" datafile="${dir.build.cobertura}/cobertura.ser" destdir="${dir.build.cobertura}/" />
    <cobertura-report format="html" datafile="${dir.build.cobertura}/cobertura.ser" destdir="${dir.build.cobertura}/" />
</target>

The problem is, the classes are in the build/cobertura/classes directory. And I can’t figure out, why Junit, can’t find the classes

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T14:16:21+00:00Added an answer on June 12, 2026 at 2:16 pm

    Your classpath:

        <classpath>
            <!--<pathelement path="build/cobertura/classes" />-->
            <path refid="path.UNITTEST" />
    
        </classpath>
    

    Contains:

    <path id="path.LIB">
        <fileset dir="lib" includes="**/**.jar" />
    </path>
    
    <path id="path.UNITTEST">
        <path refid="path.LIB" />
        <pathelement path="build/cobertura/classes" />
        <pathelement path="build/classes" />
        <pathelement path="build/test-classes" />
    </path>
    

    But it also needs the cobertura jars, which you reference in path.additionaltasks. Cobertura instruments the class files with byte code manipluation. Those files still need the cobertura.jar dependency to work.
    To fix it add the path.additionaltasks to junit:

        <classpath>
            <!--<pathelement path="build/cobertura/classes" />-->
            <path refid="path.UNITTEST" />
            <path refid="path.additionaltasks" />
        </classpath>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have question about sending emails from MVC3 application. I already read for exmple
i have question about two different Bundle object in below methods : onSaveInstanceState(Bundle outState);
I have question about global variable in Objective-C. I have two .m files :
I'm learning asp.net. I have question about example buttons I can use two types
https://stackoverflow.com/a/64983/468251 - Hello, I have question about this code, how made that working with
I have question about parsing in Html helper : I have sth like: @foreach
I have question about clean thory in Python. When: @decorator_func def func(bla, alba): pass
I have question about XSLT1.0. The task is to write out in HTML all
I have question about normalization. Suppose I have an applications dealing with songs. First
I have question about interpreting strings as packed binary data in C++. In python,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.