From: Grzegorz L. <ha...@gm...> - 2005-08-23 19:45:13
|
Hey, You probably do not set property net.sourceforge.cobertura.datafile when running tests (I do not know how to do it inside cactus task). Do you get additional cobertura.ser in directory where tests are run? Grzegorz On 8/23/05, yamaduc <ya...@gm...> wrote: > Hi all, >=20 > I have the following build script. >=20 > <target name=3D"instrument" depends=3D"compile" description=3D"Add Cobert= ura > instrumentation"> > <!-- instrument the application classes, writing the inst= rumented > classes into ${instrumented.classes}. --> >=20 > <cobertura-instrument datafile=3D"${test.dir}/cobertura.s= er" > todir=3D"${instrumented.classes}"> > <!-- Note that the following line causes instrume= nt to ignore any > source line containing a reference to log4j,= for the purposes > of coverage reporting. --> > <ignore regex=3D"org.apache.log4j.*"/> >=20 > <fileset dir=3D"${classes.dir}"> > <!-- instrument all the application class= es, but don't instrument > the test classes. --> > <include name=3D"**/*.class"/> > <exclude name=3D"**/*Test.class"/> > </fileset> > </cobertura-instrument> >=20 > </target> >=20 > <target name=3D"test" depends=3D"prepare.test.package" description=3D"Run > the tests on the defined container"> > <!-- Run the tests --> > <mkdir dir=3D"${test.results}/tomcat4x"/> > <cactus warfile=3D"${test-war.dir}/${app.name}-${app.vers= ion}.war" > fork=3D"yes" failureproperty=3D"tests.failed" haltonerror=3D"true"> >=20 >=20 > <!-- Configure the cactus task for logging --> > <cactusproperty server=3D"false" > propertiesFile=3D"${meta.dir}/${configtyp= e}/test/logging_client.properties"/> > <cactusproperty server=3D"true" > propertiesFile=3D"${meta.dir}/${configtyp= e}/test/logging_server.properties"/> >=20 > <!-- Additional jars that will be added to the cl= asspath used to start the > container (in addition to the container = jars themseleves which are > automatically added by the <cactus> task= --> > <containerclasspath> > <pathelement path=3D"${test-props.dir}"/> > </containerclasspath> >=20 >=20 > <classpath> > <pathelement path=3D"${instrumented.class= es}"/> > <pathelement path=3D"${classes.dir}"/> > <pathelement location=3D"${test-lib.dir}/= my-tests.jar"/> > <path refid=3D"project.classpath"/> > </classpath> >=20 >=20 > <containerset> > <tomcat4x if=3D"tomcat-dist.dir" > dir=3D"${tomcat-dist.di= r}" port=3D"${test.port}" > output=3D"${test.result= s}/tomcat4x.out" > todir=3D"${test.results= }/tomcat4x" > tmpdir=3D"${test.temp.d= ir}" > jvmArgs=3D"-DGG_HOME=3D= C:/test"/> > </containerset> >=20 > <formatter type=3D"brief" usefile=3D"false"/> > <formatter type=3D"xml"/> >=20 > <batchtest> > <fileset dir=3D"${testsrc.dir}"> > <include name=3D"**/Test*.java"/> > <exclude name=3D"**/Test*All.java= "/> > </fileset> > </batchtest> >=20 > </cactus> > <!-- Generate the JUnit reports --> >=20 > <junitreport todir=3D"${test.results}/tomcat4x"> > <fileset dir=3D"${test.results}/tomcat4x" > includes=3D"TEST-*.xml"/> > <report todir=3D"${test.results}/tomcat4x" > format=3D"frames"/> > </junitreport> >=20 > <fail if=3D"tests.failed">At least one test failed!</fail= > >=20 > </target> >=20 > <target name=3D"coverage" description=3D"HTML coverage reports can be > found in build/coverage"> >=20 > <mkdir dir=3D"${test.results}/coverage"/> > <cobertura-report srcdir=3D"${src.dir}" > destdir=3D"${test.results}/coverage" > datafile=3D"${test.dir}/cobertura.ser"/> >=20 > <echo> > Cobertura reports have been generated. > The HTML report is ${test.results}/coverage/index= .html > </echo> >=20 > </target> >=20 >=20 > I'm getting 0% coverage for all tests. >=20 > Is there a way to see if the classes have been instrumented? >=20 >=20 > ------------------------------------------------------- > SF.Net email is Sponsored by the Better Software Conference & EXPO > September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practic= es > Agile & Plan-Driven Development * Managing Projects & Teams * Testing & Q= A > Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf > _______________________________________________ > Cobertura-devel mailing list > Cob...@li... > https://lists.sourceforge.net/lists/listinfo/cobertura-devel > |