扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
作者:中国IT实验室 来源:中国IT实验室 2007年9月24日
关键字:
在本页阅读全文(共2页)
<!? - - - - - - - - - - - - - - - - -
target: init
initialize the build env. for code coverage
- - - - - - - - - - - - - - - - - ?>
<target name="init-coverage" description="initialize the build env.">
<!? create the output folder ?>
<mkdir dir="${instrumented-dir}" />
<mkdir dir="${cobertura-dir}" />
<mkdir dir="${cobertura-xml-dir}" />
<mkdir dir="${cobertura-html-dir}" />
</target>
<target name="compile-coverage" depends="init">
<javac srcdir="${src-dir}:${testcase-dir}" destdir="${out-dir}" debug="true" >
<classpath refid="cobertura.classpath" />
</javac>
</target>
<!? =================================
target: instrument
Instrument into the class files, but
exclude test classes
================================= ?>
<target name="instrument" depends="init-coverage,compile-coverage" description="instrument into the class files">
<!?
Instrument the application classes, writing the
instrumented classes into ${instrumented.dir}.
?>
<cobertura-instrument todir="${instrumented-dir}" datafile="${instrument-file}">
<!?
The following line causes instrument to ignore any
source line containing a reference to log4j, for the
purposes of coverage reporting.
?>
<ignore regex="org.apache.log4j.*" />
<fileset dir="${out-dir}">
<!?
Instrument all the application classes, but
don’t instrument the test classes.
?>
<include name="**/*.class" />
<exclude name="**/Test*.class" />
</fileset>
</cobertura-instrument>
</target>
<!? =================================
target: coverage-check
check the code coverage by given rates.
================================= ?>
<target name="coverage-check" description="check the code coverage by given rates">
<cobertura-check branchrate="34" totallinerate="100" />
</target>
<!? =================================
target: coverage-report-xml
generate code coverage report by xml format
================================= ?>
<target name="coverage-report-xml" description="generate xml report">
<!? Generate an XML file containing the coverage data using the "srcdir" attribute. ?>
<cobertura-report srcdir="${src-dir}" destdir="${cobertura-xml-dir}" format="xml" datafile="${instrument-file}"/>
</target>
<!? =================================
target: coverage-report-html
generate code coverage report by html format
================================= ?>
<target name="coverage-report-html">
<!?
Generate a series of HTML files containing the coverage
data in a user-readable form using nested source filesets.
?>
<cobertura-report destdir="${cobertura-html-dir}" datafile="${instrument-file}">
<fileset dir="${src-dir}">
<include name="**/*.java"/>
</fileset>
</cobertura-report>
</target>
<!? run the code coverage individual ?>
<target name="coverage" depends="compile-coverage,instrument,test,coverage-report-html"
description="Compile, instrument ourself, run the tests and generate JUnit and code coverage reports."/>
<!? =================================================================== ?>
<!? Public Targets ?>
<!? =================================================================== ?>
<target name="clean">
<delete quiet="true" includeEmptyDirs="true">
<fileset dir="${report-dir}">
<exclude name=".cvsignore" />
<exclude name="CVS" />
</fileset>
<fileset dir="${out-dir}">
</fileset>
</delete>
</target>
<!? =================================================================== ?>
<!? Global Targets ?>
<!? =================================================================== ?>
<target name="all" depends="compile" />
<target name="junit" depends="clean, compile-test, test" />
<target name="full" depends="clean, coverage" />
</project>
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者