mouseweiwei 发表于 2008-8-13 18:01:00

请教ant+junit里 junitreport如何使用

请教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><!]></doctitle>
<bottom><!]></bottom>
<tag name="todo" scope="all" description="To do:" />
</javadoc>
</target>
</project>


console中
Buildfile: D:\workspace\Hello\build.xml
init:
compile:
    Warning: example\CalculatorR.java modified in the future.
    Warning: example\TestCalculator.java modified in the future.
    Compiling 2 source files to D:\workspace\Hello\classes
test:
    Running src.example.TestCalculator
    Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 0.172 sec
pack:
       Building jar: D:\workspace\Hello\dist\hello.jar
doc:
Generating Javadoc
Javadoc execution
Loading source files for package example...
Constructing Javadoc information...
javadoc: warning - No source files for package example
javadoc: error - No public or protected classes found to document.
1 error
1 warning
BUILD SUCCESSFUL
Total time: 4 seconds

其中 test后的 report任务没有去做 google里查询相关帖子说是要用 junitreport 需要一个 xalan.jar包 我在apache上下到个2.7.1版本的 在eclipse里导过了 但还是不行请教高手该如何执行junitreport

fly 发表于 2008-9-3 10:32:35

编译就没有过,如何做后面的任务
页: [1]
查看完整版本: 请教ant+junit里 junitreport如何使用