|
请教junitreport 的具体配置方法
<?xml version="1.0" encoding="UTF-8"?>
<project name="Hello world" default="doc">
<!-- properies -->
<property name="src.dir" value="src" />
<property name="report.dir" value="report" />
<property name="classes.dir" value="classes" />
<property name="lib.dir" value="lib" />
<property name="dist.dir" value="dist" />
<property name="doc.dir" value="doc"/>
<!-- 定义classpath -->
<path id="master-classpath">
<fileset file="${lib.dir}/*.jar" />
<pathelement path="${classes.dir}"/>
</path>
<!-- 初始化任务 -->
<target name="init">
</target>
<!-- 编译 -->
<target name="compile" depends="init" description="compile the source files">
<mkdir dir="${classes.dir}"/>
<javac srcdir="${src.dir}" destdir="${classes.dir}">
<classpath refid="master-classpath"/>
</javac>
</target>
<!-- 测试 -->
<target name="test" depends="compile" description="run junit test">
<mkdir dir="${report.dir}"/>
<junit printsummary="yes">
<classpath refid="master-classpath"/>
<formatter type="xml"/>
<batchtest todir="${report.dir}">
<fileset dir="${classes.dir}">
<include name="**/Test*.*"/>
</fileset>
</batchtest>
</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>
<!-- 打包成jar -->
<target name="pack" depends="test" description="make .jar file">
<mkdir dir="${dist.dir}" />
<jar destfile="${dist.dir}/hello.jar" basedir="${classes.dir}">
<exclude name="**/*Test.*" />
<exclude name="**/Test*.*" />
</jar>
</target>
<!-- 输出api文档 -->
<target name="doc" depends="pack" description="create api doc">
<mkdir dir="${doc.dir}" />
<javadoc destdir="${doc.dir}"
author="true"
version="true"
use="true"
windowtitle="Test API">
<packageset dir="${src.dir}" defaultexcludes="yes">
<include name="example/**" />
</packageset>
<doctitle><![CDATA[<h1>Hello, test</h1>]]></doctitle>
<bottom><![CDATA[<i>All Rights Reserved.</i>]]></bottom>
<tag name="todo" scope="all" description="To do:" />
</javadoc>
</target>
</project>
console中
Buildfile: D:\workspace\Hello\build.xml
init:
compile:
[javac] Warning: example\CalculatorR.java modified in the future.
[javac] Warning: example\TestCalculator.java modified in the future.
[javac] Compiling 2 source files to D:\workspace\Hello\classes
test:
[junit] Running src.example.TestCalculator
[junit] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 0.172 sec
pack:
[jar] Building jar: D:\workspace\Hello\dist\hello.jar
doc:
[javadoc] Generating Javadoc
[javadoc] Javadoc execution
[javadoc] Loading source files for package example...
[javadoc] Constructing Javadoc information...
[javadoc] javadoc: warning - No source files for package example
[javadoc] javadoc: error - No public or protected classes found to document.
[javadoc] 1 error
[javadoc] 1 warning
BUILD SUCCESSFUL
Total time: 4 seconds
其中 test后的 report任务没有去做 google里查询相关帖子说是要用 junitreport 需要一个 xalan.jar包 我在apache上下到个2.7.1版本的 在eclipse里导过了 但还是不行 请教高手该如何执行junitreport |
|