??xml version="1.0" encoding="utf-8" standalone="yes"?>
而且q是一个绿色YӞ不需要Q何的安装Q双击exe文gq行卛_。卸载时只需要把exe和cfg文g删除卛_?nbsp; 阅读全文
]]><project name="autobuildtest" default="test">
<target name="setProperties">
<property name="src.dir" value="src"/>
<property name="classes.dir" value="classes"/>
</target>
<target name="prepareDir" depends="setProperties">
<delete dir="${classes.dir}"/>
<mkdir dir="${classes.dir}"/>
</target>
<target name="compile" depends="prepareDir">
<javac srcdir="./src" destdir="${classes.dir}"/>
</target>
<target name="test" depends="compile">
<junit printsummary="yes">
<test name="onlyfun.caterpillar.test.MathToolTest"/>
<classpath>
<pathelement location="${classes.dir}"/>
</classpath>
</junit>
</target>
</project>
上面XML文g高亮处描qCAnt如何与JUnitl合q行自动化测试,name属性是你要试的TestCaseQclasspath元素指明了TestCase的\径,printsummary说明了要测试的l果单的昄出来?br style="font-family: " />
如何吧JUnit试的详l信息显C出来呢Q我们可以采?lt;formatter>元素Q如下所C:
<junit printsummary="yes">
<formatter type="plain" usefile="false"/>
<test name="onlyfun.caterpillar.test.MathToolTest"/>
<classpath>
<pathelement location="${classes.dir}"/>
</classpath>
</junit>
当usefile属性设定ؓtrueӞ会自动帮您将产生的结果储存在档案中,预设是TEST-*.txtQ其?是您的测试案例类别名U。除此之外,我们也可用采用XML的格式来保存试l果。如下所C:
<formatter type="xml"/>
也可以将试l果所产生的XML文g转换为HTML文gQ用Ant可以直接帮您完成q个工作Q?lt;junitreport>标签使用 XSLTXML文g转换为HTML文g
<project name="autobuildtest" default="report">
<target name="setProperties">
<property name="src.dir" value="src"/>
<property name="classes.dir" value="classes"/>
<property name="report.dir" value="report"/>
</target>
<target name="prepareDir" depends="setProperties">
<delete dir="${report.dir}"/>
<delete dir="${classes.dir}"/>
<mkdir dir="${report.dir}"/>
<mkdir dir="${classes.dir}"/>
</target>
<target name="compile" depends="prepareDir">
<javac srcdir="./src" destdir="${classes.dir}"/>
</target>
<target name="test" depends="compile">
<junit printsummary="yes">
<formatter type="xml"/>
<test name="onlyfun.caterpillar.test.MathToolTest"
todir="${report.dir}"/>
<classpath>
<pathelement location="${classes.dir}"/>
</classpath>
</junit>
</target>
<target name="report" depends="test">
<junitreport todir="${report.dir}">
<fileset dir="${report.dir}">
<include name="TEST-*.xml"/>
</fileset>
<report format="frames" todir="${report.dir}/html"/>
</junitreport>
</target>
</project>
上面的例子,首先定义了一个propertyQ用于指向保存测试结果的目录Q接着?lt;test>元素中通过<todir>结果指向该目录。然后report目标首先在todir属性指定的目录下查扑U包含:TESTd的XML文gQ找C后通过XSL转换成带frame的HTML面Q存攑ֈ子目录html下面
最l的l果可能如下Q?br />
]]>
<classpath>
<pathelement path="${classpath}"/>
<pathelement location="lib/helper.jar"/>
</classpath>
原文QThe location attribute specifies a single file or directory relative to the project's base directory (or an absolute filename), while the path attribute accepts colon- or semicolon-separated lists of locations. The path attribute is intended to be used with predefined paths - in any other case, multiple
elements with location attributes should be preferred.
从中我们可以看出path可以用于指向存在多个文g的位|,而location只能指向单个的文件或目录。另外path可以被设定idQ供其它的path或classpath引用。如Q?lt;path id="main-classpath">Q而classpath则没?/span>
?】综合示例:
In addition, DirSets, FileSets, and FileLists can be specified via nested <dirset>, <fileset>, and <filelist> elements, respectively. Note: The order in which the files building up a FileSet are added to the path-like structure is not defined.
<classpath>
<pathelement path="${classpath}"/> 方式?Q引用特定的变量
<fileset dir="lib"> 方式?Q指向特定的文g?/strong>
<include name="**/*.jar"/>
</fileset>
<pathelement location="classes"/> 方式③:指向单个目录
<dirset dir="${build.dir}"> 方式④:指向特定目录?/strong>
<include name="apps/**/classes"/>
<exclude name="apps/**/*Test*"/>
</dirset>
<filelist refid="third-party_jars"/> 方式⑤:引用指定文g列表
</classpath>
This builds a path that holds the value of ${classpath}, followed by all jar files in the lib directory, the classes directory, all directories named classes under the apps subdirectory of ${build.dir}, except those that have the text Test in their name, and the files specified in the referenced FileList.