1

i want to take code coverage for my application.This is my build.xml file.

<property name="src.dir"     value="src"/>
<property name="coverage.dir"   value="coverage"></property>
<property name="lib.dir"     value="lib"/>
<property name="build.dir"   value="build"/>
<property name="FS" value="${file.separator}" />
<property name="classes.dir" value="${build.dir}/classes"/>
<property name="jar.dir"     value="${build.dir}/jar"/>
<property name="main-class"  value="com.test.main.Control"/>
<property name="emma.enabled" value="true" />


<path id="emma.lib" >
    <pathelement location="${lib.dir}/emma.jar" />
    <pathelement location="${lib.dir}/emma_ant.jar" />
</path>

<taskdef resource="emma_ant.properties" classpathref="emma.lib" />

<path id="classpath">
    <fileset dir="${lib.dir}" includes="**/*.jar"/>
    <!--fileset dir="${lib.dir}" includes="**/log4j.properties"/-->
</path>

<target name="clean">
    <delete dir="${build.dir}"/>
</target>

<target name="compile">
    <mkdir dir="${classes.dir}"/>
    <javac srcdir="${src.dir}" destdir="${classes.dir}" includeantruntime="false" classpathref="classpath" debug="on"/>
    <!--copy todir="${{classes.dir}" file="${src.dir}${FS}hibernate.cfg.xml" /-->
</target>

<target name="jar" depends="compile">
    <mkdir dir="${jar.dir}"/>
    <jar destfile="${jar.dir}/${ant.project.name}.jar" basedir="${classes.dir}">
        <manifest>
            <attribute name="Main-Class" value="${main-class}"/>
        </manifest>
    </jar>
</target>

<target name="emma" description="turns on EMMA's on-the-fly instrumentation mode" >
    <property name="emma.enabled" value="true" />
     <!-- EMMA instr class output directory: -->
    <property name="out.instr.dir" value="outinstr" />
    <mkdir dir="${out.instr.dir}" />
</target>


    <emma enabled="${emma.enabled}" >
        <report sourcepath="${src.dir}" >
            <fileset dir="${coverage.dir}" >
                <include name="*.emma" />
            </fileset>

            <txt outfile="${coverage.dir}/coverage.txt" />
            <html outfile="${coverage.dir}/coverage.html" />
        </report>
    </emma>

</target>

<!--target name="clean-build" depends="clean,jar"/-->

<target name="main" depends="clean,run"/>

when i run "ant emma run" command, getting the exception

[java] Error: Could not find or load main class com.test.main.Control [java] Java Result: 1

Please let me know how to resolve this.

santro
  • 373
  • 1
  • 6
  • 22

0 Answers0