Ant工程执行测试后的目录结构如下:
构建文件(build.xml),有中文可能会报错
<?xml version="1.0"?> <project name="secondbuild" default="compile"> <!--test class name--> <property name="test.suite" value="org.antbook.service.StudentServiceTest" /> <property environment="env" /> <echo>test=${env.JAVA_HOME}</echo> <target name="init"> <mkdir dir="build/classes" /> <mkdir dir="build/test/classes" /> <mkdir dir="dist" /> <mkdir dir="build/test/data" /> <mkdir dir="build/test/report" /> </target> <target name="clean" > <delete dir="build" /> <delete dir="dist" /> </target> <target name="compile" depends="init"> <javac srcdir="src" destdir="build/classes" /> </target> <!--test compile:需要build/classes目录中的class文件,因为测试代码使用的源码--> <target name="test-compile" depends="init,compile"> <javac destdir="build/test/classes"> <src path="test" /> <classpath refid="test.compile.classpath" /><!--使用了build/classes中的class--> </javac> </target> <!--junit test--> <target name="junit" depends="test-compile" > <junit> <classpath refid="test.run.classpath" /> <test name="${test.suite}" /> <test name="org.antbook.service.EventServiceTest" /> </junit> </target> <!--batch junit test, report--> <target name="batch-junit-test" depends="test-compile" > <!--测试失败后并不会直接跳到<fail>任务,<target>中的任务是顺序执行的--> <junit printsummary="yes" haltonfailure="false" errorProperty="test.failed" failureProperty="test.failed"> <classpath refid="test.run.classpath" /> <formatter type="xml" /> <!--格式化格式化器--> <batchtest fork="yes" todir="build/test/data"><!--生成的xml测试报告存放的位置--> <fileset dir="build/test/classes" includes="**/*Test.class" /> </batchtest> </junit> <!--应该放到<fail>任务之前,这样才会根据xml产生html文档--> <junitreport todir="build/test/data"> <!--将TESTS-TestSuites.xml文件存放于该目录--> <fileset dir="build/test/data"> <!--根据这些xml文件生成TESTS-TestSuites.xml(固定),打开TESTS-TestSuites.xml文件可以看见该文件包含了这些xml中的信息--> <include name="TEST-*.xml"/> </fileset> <report format="frames" todir="build/test/report" /> <!--Ant会根据TESTS-TestSuites.xml(固定)生成html测试报告--> </junitreport> <!--如果名为test.failed的特征存在,则输出异常信息--> <fail if="test.failed"> Test failed......................... </fail> <!--如果<fail>任务后面有任务 都不会被执行,但是在<fail>任务前面的任务还会被继续执行--> <echo>test print....</echo> </target> <!--compile classpath--> <path id="compile.classpath" > <fileset dir="lib"> <include name="*.jar" /> </fileset> </path> <!--run classpath--> <path id="run.classpath"> <path refid="compile.classpath" /> <pathelement path="build/classes" /> </path> <!--test compile classpath--> <path id="test.compile.classpath"> <path refid="compile.classpath" /> <pathelement path="build/classes" /> </path> <!--test run classpath--> <path id="test.run.classpath"> <path refid="test.compile.classpath" /> <pathelement path="build/test/classes" /> </path> </project>
相关推荐
ant+junit的简易教程
ant1.8.2+junit4.8.1 自动编译,自动测试,自动生成测试报告 只要把你下载的zip包解压,cmd到对应目录下,直接ant命令就可以。当然前提是你要配置好ANT_HOME, 并把ant命令加到Path中。 zip包中,有build文件夹,有...
JUnit 5 = JUnit Platform + JUnit Jupiter + JUnit Vintage,包含依赖包:junit-jupiter-5.5.1.jar,junit-jupiter-engine-5.5.1.jar,junit-jupiter-params-5.5.1.jar,junit-platform-launcher-1.5.1.jar,junit-...
没有什么好说的,这是我配置的过程,拿出来大家分享,希望对您的工作有帮助
Ant+Junit+Svn实现自动单元测试
Junit+ant+cobertura示例源码程序。
hibernate+spring +ant+junit 1.整合hibernate+spring 2.ant自动生成xml文件和api 3.junit测试hql语句 4.c标签写的前台分页程序
ant+junit程序小实例(绝对可以运行)
内容概要:参考Mockito官方API文档,实践框架每个特性。 适合人群:Mockito入门人员以及想全面...能学到什么:“Mockito 4.6.0 + Junit 5”的组合编程。 使用建议:使用前安装好Maven及Java即可,推荐使用VSCode编辑。
hibernate+spring+junit+ant+mysql 小实例。能够当模板
junit4.3工具包是Android开发中常用的包,希望对大家有所帮助
Ant+JUnit测试报告实际例子 资源分6分,希望物有所值而不是“无有所值”。
Selenium+Eclipse+Junit+TestNG,Selenium自动化测试框架以及使用步骤_详细备注
NULL 博文链接:https://majm.iteye.com/blog/509634
maven+spring+mybatis+mysql+junit jar项目框架搭建
配置junit用ant配置运行,里面介绍了如果配置,如果运行
selenium+java+junit的使用,可以提供给正在学习软件测试的学弟学妹们借鉴和参考!
junit-4.0.jar
selenium+junit+hudson自动化测试初探