【学习笔记】系列十五:Ant单元测试JUnit
来源:互联网 发布:用ps做淘宝店长图 编辑:程序博客网 时间:2024/06/05 07:34
好了,接下来继续Ant,有关单元测试,涉及到JUnit和TestNG
首先来说JUnit,执行用例很简单,但是大部分人应该不仅仅需要执行,更多的是想要得到测试报告
JUnit自生成.xml格式的测试报告,不过可视性不是很好,需要整理
而且,IDE下的JUnit执行后,测试报告是不自动储存的
Demo如下:
这次的代码是自己的,不会出现xxxx了
<?xml version="1.0" encoding="UTF-8"?><project name="TestJekinsJunit" default="junit" basedir="."> <!-- ========== --> <!-- 变量设置 --> <!-- ========== --> <!-- 源代码路径 --> <property name="src.path" location="src/com/doulei/jenkins/junit/test/calculator"/> <!-- 编译文件class路径 --> <property name="build.path" location="build/"/> <!-- 单元测试代码路径 --> <property name="test.path" location="src/com/doulei/jenkins/junit/test/cases"/> <!-- lib包路径 --> <property name="lib.path" value="lib/"/> <!-- 生成报告xml路径 --> <property name="report.path" value="report/"/> <!-- ========== --> <!-- 设置classpath --> <!-- ========== --> <path id="compile.path"> <fileset dir="${lib.path}"> <include name="**/*.jar"/> </fileset> <pathelement path="${build.path}"/> </path> <!-- ========== --> <!-- 清除历史文件 --> <!-- ========== --> <target name="clean"> <delete dir="${build.path}"/> <delete dir="${report.path}"/> </target> <target name="init" depends="clean"> <mkdir dir="${build.path}"/> <mkdir dir="${report.path}"/> </target> <!-- ========== --> <!-- 编译文件 --> <!-- ========== --> <target name="compile" depends="init" description="compile"> <javac srcdir="${src.path}" destdir="${build.path}" includeAntRuntime="false" debug="on" encoding="utf-8" classpathref="compile.path"/> <javac srcdir="${test.path}" destdir="${build.path}" includeAntRuntime="false" debug="on" encoding="utf-8" classpathref="compile.path"/> </target> <!-- ========== --> <!-- 执行测试案例 --> <!-- ========== --> <target name="junit" depends="compile"> <junit printsummary="true" fork="true"> <formatter type="xml" usefile="true"/> <classpath refid="compile.path"/> <batchtest fork="on" todir="${report.path}" haltonfailure="no"> <fileset dir="${build.path}"> <include name="**/*Test.class"/> </fileset> </batchtest> </junit> <!-- 产生测试报告文档 --> <junitreport todir="${report.path}"> <fileset dir="${report.path}"> <include name="TEST-*.xml"/> </fileset> <report format="frames" todir="${report.path}"/> </junitreport> </target></project>
Ant执行后,打开report路径下的index.html即可看到测试报告详情
加一张报告页面截图
0 0
- 【学习笔记】系列十五:Ant单元测试JUnit
- 【学习笔记】系列十六:Ant单元测试TestNG
- Junit单元测试学习笔记一
- Junit单元测试学习笔记二
- Junit单元测试学习笔记三
- ANT教程之十五 Ant Junit集成
- Androidx学习笔记(18)-- junit单元测试
- JUnit学习笔记4---Ant的一天
- JUnit学习笔记4---Ant的一天
- #Vi,java,Ant,Junit学习笔记
- Junit单元测试笔记
- JUnit单元测试笔记
- Junit单元测试笔记
- Junit单元测试学习01
- Junit单元测试学习02
- 单元测试JUNIT使用学习
- myeclipse junit 单元测试学习
- 学习JUnit单元测试
- 启动 Eclipse提示“Failed to load the JNI shared library jvm.dll”
- ASP.NET AJAX Advance Tips & Tricks (3) JavaScript与Tab的交互
- 《Android Studio项目结构(一)——目录列表》
- ASP.NET AJAX Advance Tips & Tricks (4) ASP.NET AJAX Performance Improvement
- js对象爆炸的简单示例
- 【学习笔记】系列十五:Ant单元测试JUnit
- org.apache.commons.lang.StringUtils源码
- Python自动化面试必备 之 你真明白装饰器么?
- Android 系统架构
- ssh公私钥正确的情况下免密登录失败原因
- python连接sql server并执行查询操作
- 设计模式-中介者模式
- Plugin with id 'me.tatarka.retrolambda' not found.
- C# ??合并运算符