From: John W. L. <Joh...@sa...> - 2011-06-23 16:23:30
|
That is a strange error. Your script looks pretty good, but I would try removing these lines: <path id="cobertura.classpath"> <fileset dir="${basedir}\jenkins\cobertura" includes="**/*.jar"/> <pathelement location="target/instrumented-classes"/> <pathelement location="${dir.src}"/> </path> Also, make sure the instrumented classes are first: <path id="cover-test.classpath"> <pathelement location="target/instrumented-classes"/> <pathelement location="${dir.build}"/> <fileset dir="${dir.dist}" includes="**/*.jar"/> </path> After you do these changes, try commenting out the call to <cobertura-instrument> and make sure the tests pass without the instrumentation. If they do, then let me know. John From: Ken Louie [mailto:klo...@gm...] Sent: Wednesday, June 22, 2011 7:18 PM To: cob...@li... Subject: [Cobertura-devel] Need Help With Ant Tasks Hello, I'm having trouble using the cobertura ant tasks. If someone could help me I would greatly appreciate it. When I try to run junit tests using the instrumented classes I get the following errors for each class I try to run the junit test on: Testsuite: test.classes.com.lmco.isgs.security.wamix.agentproxy.proxy.IAgentProxyFactoryTest Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0 sec & nbsp; Caused an ERROR test/classes/com/lmco/isgs/security/wamix/agentproxy/proxy/IAgentProxyFactoryTest (wrong name: com/lmco/isgs/security/wamix/agentproxy/proxy/IAgentProxyFactoryTest) java.lang.NoClassDefFoundError: test/classes/com/lmco/isgs/security/wamix/agentproxy/proxy/IAgentProxyFactoryTest (wrong name: com/lmco/isgs/security/wamix/agentproxy/proxy/IAgentProxyFactoryTest) at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631) at java.lang.ClassLoader.defineClass(ClassLoader.java:615) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141) at java.net.URLClassLoader.defineClass(URLClassLoader.java:283) at java.net.URLClassLoader.access$000(URLClassLoader.java:58)   ; at java.net.URLClassLoader$1.run(URLClassLoader.java:197) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at java.lang.ClassLoader.loadClass(ClassLoader.java:306) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:247) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:169) Here are how my ant tasks look like: <?xml version="1.0" ?> <project name="cobert ura" default="cobertura" basedir=".."> <property name="dir.src" value="src"/> <property name="dir.build" value="build"/> <property name="dir.dist" value="dist"/> <property name="dir.lib" value="lib"/> <property name="dir.report" value="report"/> &n bsp; <path id="cobertura.classpath"> <fileset dir="${basedir}\jenkins\cobertura" includes="**/*.jar"/> <pathelement location="target/instrumented-classes"/> <pathelement location="${dir.src}"/> </path> <taskdef classpath="${basedir}\jenkins\cobertura\cobertura.jar" resource="tasks.properties" classpathref="cobertura.cla sspath"/> <!-- adds the logging code to the already compiled class files --> <target name="instrument"> <delete quiet="false" failonerror="false"> <fileset dir="target/instrumented-classes" includes="**/*.class"/> </delete> <cobertura-instrument todir="target/instrumented-classes"> <fileset dir="${dir.build}"> <include name="**/*.class"/> <exclude name="**/*Test.class"/> </fileset> </cobertura-instrument> </target> <!-- setup class path to include instrumented classes before n on-instrumented ones --> <path id="cover-test.classpath"> <fileset dir="${dir.dist}" includes="**/*.jar"/> <pathelement location="target/instrumented-classes"/> <pathelement location="${dir.build}"/> </path> <!-- run all my junit tests using the instrumented classes --> < ;target name="cover-test" depends="instrument"> <mkdir dir="${dir.report}/cobertura" /> <junit printsummary="yes" haltonerror="no" haltonfailure="no" fork="yes"> <formatter type="plain" usefile="true"/> <batchtest> <fileset dir="${dir.build}" includes="**/*Test.class" /> </bat chtest> <classpath refid="cover-test.classpath"/> </junit> </target> <!-- create the html reports --> <target name="coverage-report" depends="cover-test"> <cobertura-report srcdir="${dir.src}" destdir="${dir.report}" datafile="cobertura.ser" format="html"/> </target> </project> Again, if someone could help me out in anyway, I would greatly appreciate it. Thanks, Ken Louie |