您的位置:首页 > 其它

Ant 使用Junit自动测试要注意的问题

2007-05-16 13:56 441 查看
在构建Ant自动测试的时候,必须要加入ant_home/lib下的库,要不会出现ClassNotFound的异常。

 


    <path id="test.classpath">


        <fileset dir="${ant.library.dir}">


            <include name="*.jar"/>


        </fileset>


        <pathelement location="${test.home}/classes"/>


    </path>


    <target name="test" depends="all">


        <mkdir dir="${test.report}"/>


        <mkdir dir="${test.home}/classes"/>


        <javac srcdir="${test.home}/src"


               destdir="${test.home}/classes"


               debug="${compile.debug}"


               deprecation="${compile.deprecation}"


               optimize="${compile.optimize}">


            <classpath refid="master-classpath"/>




        </javac>




        <junit printsummary="true"


               fork="true"


               haltonfailure="false"


               failureproperty="tests.failed"


               showoutput="true">


            <classpath refid="test.cl
4000
asspath"/>


            <classpath refid="master-classpath"/>


            <formatter type="xml"/>


            <batchtest todir="${test.report}">


                <fileset dir="${test.home}/classes">


                    <include name="**/*Test.*"/>


                </fileset>


            </batchtest>


        </junit>


        <junitreport todir="${test.report}">


            <fileset dir="${test.report}">


                <include name="TEST-*.xml"/>


            </fileset>


            <report format="frames" todir="${test.report}"/>


        </junitreport>


        <fail if="tests.failed">


            ---------------------------------------------------------


            One or more tests failed, check the report for detail...


            ---------------------------------------------------------


        </fail>


    </target>

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息