栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

如何在Ant生成脚本中运行JUnit测试,同时从生成的jar中省略测试类?

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

如何在Ant生成脚本中运行JUnit测试,同时从生成的jar中省略测试类?

根据@Jon的建议,我将junit目标更改为针对build / classes文件夹而不是jar运行,并适当地更新了依赖项。

我更新的build.xml文件如下:

<project name="HelloWorld" basedir="." default="main">    <property name="src.dir"     value="src"/>    <property name="build.dir"   value="build"/>    <property name="classes.dir" value="${build.dir}/classes"/>    <property name="jar.dir"     value="${build.dir}/jar"/>    <property name="lib.dir"     value="lib"/>    <property name="report.dir"  value="${build.dir}/junitreport"/>    <property name="main-class"  value="oata.HelloWorld"/>    <path id="classpath">        <fileset dir="${lib.dir}" includes="***.java"/>        </copy>    </target>    <target name="jar" depends="junit">        <mkdir dir="${jar.dir}"/>        <jar destfile="${jar.dir}/${ant.project.name}.jar" basedir="${classes.dir}" excludes="**/*Test.class"> <manifest>     <attribute name="Main-Class" value="${main-class}"/> </manifest>        </jar>    </target>    <target name="junit" depends="compile">        <mkdir dir="${report.dir}"/>        <junit printsummary="yes" haltonfailure="yes" showoutput="yes"> <classpath>     <path refid="classpath"/>     <path location="${classes.dir}"/> </classpath> <formatter type="xml"/> <batchtest fork="yes">     <fileset dir="${src.dir}" includes="*Test.java"/> </batchtest>        </junit>    </target>    <target name="junitreport" depends="junit">        <junitreport todir="${report.dir}"> <fileset dir="${report.dir}" includes="TEST-*.xml"/> <report todir="${report.dir}"/>        </junitreport>    </target>    <target name="run" depends="jar">        <java fork="true" classname="${main-class}"> <classpath>     <path refid="classpath"/>     <path refid="application"/> </classpath>        </java>    </target>    <target name="clean-build" depends="clean,jar"/>    <target name="main" depends="clean,run"/></project>


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/507934.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号