在ant中使用junit命令跑所有测试

<!--*************编译测试文件*****************-->

<target name="compile.functionalTest">
        <mkdir dir="${build.dir}/functionalTest"/>
        <javac srcdir="${basedir}/functionTest" destdir="${build.dir}/functionalTest" classpathref="app.classpath"/>
    </target>

<!--******************************************-->
   
    <target name="run.selenium.tests" depends="compile.functionalTest">
            <mkdir dir="${basedir}/report" />
           <!--**************这些属性可以参看ant的文档*************-->
            <junit printsummary="on" haltonfailure="false" failureproperty="functional.tests.failed"      showoutput="yes" reloading="false" fork="yes" forkmode="perBatch">
                <classpath>
                   <!--**************这个路径指的是源文件编译后的class文件和配置文件*************-->
                    <pathelement path="${build.dir}/dest/WEB-INF/classes" />
                   <!--**************这个路径指的是测试文件编译后class文件*********************-->
                    <pathelement path="${build.dir}/functionalTest"/>
    <!--**************这个路径指的是依赖的jar包*********************-->
                    <path refid="app.classpath" />
                </classpath>
                <formatter type="xml" />
               
                <sysproperty key="log4j.configuration" value="log4j.properties" />
                <sysproperty key="org.apache.commons.logging.Log" value="org.apache.commons.logging.impl.NoOpLog" />
                <batchtest todir="${basedir}/report">
                    <fileset dir="${build.dir}/functionalTest">
                        <include name="**/*Test.class" />
                    </fileset>
                </batchtest>
            </junit>
            <fail if="functional.tests.failed" message="One or more tests failed. See test output for details" />
        </target>  
posted @ 2008-10-29 17:40  Earl_86  阅读(388)  评论(0编辑  收藏  举报