`
VerRan
  • 浏览: 451503 次
  • 性别: Icon_minigender_1
  • 来自: 陕西.西安
社区版块
存档分类
最新评论

Ant 集成 junit 自动生成测试报告

    博客分类:
  • JAVA
阅读更多
在当下Maven 统治大片江山,Gradle后起之秀的情况下,此时提起Ant 难免觉得有些怀旧的意思,基于现有项目使用的主要是ant 对ant 进行了温习,对于ant 集成junit同时生成测试报告的配置做一下记录,以便后续使用。

<?xml version="1.0" encoding="UTF-8"?>
<!-- ====================================================================== 
     2013-7-26 下午4:09:09                                                        

     HBLogApp    
     This project is use for test dsc mem database.
                   
     l00211923                                                                
     ====================================================================== -->
<project name="HBLogApp" default="jarfile">
	<description>
            This project is use for analysis HB2.8 Log file.
    </description>

	<property name="src" location="src" />
	<property name="class" location="bin" />
	<property name="dist" location="resource" />
	<property name="libdir" location="lib" />
	<property name="test.src" location="test" />
	<property name="target.report.dir" location="report" />

	<!-- - - - - - - - - - - - - - - - - - 
          target: clean                      
         - - - - - - - - - - - - - - - - - -->
	<target name="clean">
		<echo message="clean class file  ..." />
		<delete dir="${class}" />
		<delete dir="${dist}" />
	</target>


	<!-- ================================= 
          target: init              
         ================================= -->
	<target name="init" description="This project is use for testHBLogApp.">
		<echo message="init ..." />
		<mkdir dir="${class}" />
		<mkdir dir="${dist}" />
	</target>


	<!-- - - - - - - - - - - - - - - - - - 
          target: compile                      
         - - - - - - - - - - - - - - - - - -->
	<target name="compile" depends="init">
		<echo message="compile source files ..." />
		<javac srcdir="src" destdir="${class}">
			<compilerarg line="-encoding GBK " />
			<classpath>
				<pathelement path="${class}" />
				<fileset dir="${libdir}">
					<include name="**/*.jar" />
				</fileset>
			</classpath>
		</javac>
	</target>

	<target name="compileTest" depends="init,compile">
		<echo message="compile source files ..." />
		<javac srcdir="test" destdir="${class}">
			<compilerarg line="-encoding GBK " />
			<classpath>
				<pathelement path="${class}" />
				<fileset dir="${libdir}">
					<include name="**/*.jar" />
				</fileset>
			</classpath>
		</javac>
	</target>

	<target name="junit" depends="compileTest">
		<mkdir dir="${target.report.dir}" />
        <junit printsummary="yes" haltonerror="yes" haltonfailure="yes" fork="yes">  
            <formatter type="plain" usefile="false"/>  
            <formatter type="xml"/>  
			<classpath>
				<pathelement path="${class}" />
				<fileset dir="${libdir}">
					<include name="**/*.jar" />
				</fileset>
			</classpath>
 
			<batchtest fork="yes" todir="${target.report.dir}">
				<fileset dir="${test.src}">
					<include name="**/*Test.java" />
				</fileset>
			</batchtest>
		</junit>
	</target>

	<target name="report" depends="junit">
		<mkdir dir="${target.report.dir}/html" />
		<!--调用junitreport来产生报告-->
		<junitreport todir="${target.report.dir}">
			<fileset dir="${target.report.dir}">
				<include name="TEST-*.xml" />
			</fileset>
			<report todir="${target.report.dir}/html" />
		</junitreport>
	</target>


	<target name="jarfile" depends="clean,init,compile,compileTest,report">
		<echo message="jar file ...." />
		<jar destfile="${dist}/hblog.jar" basedir="${class}">
		</jar>
	</target>



</project>

 

分享到:
评论

相关推荐

    unittest-xml-reporting, 基于 Ant/junit的测试 runner,类似于XML报告.zip

    unittest-xml-reporting, 基于 Ant/junit的测试 runner,类似于XML报告 unittest-xml-reportingunittest-xml-reporting是一个,测试 runner,可以以将测试结果保存到可以由生成系统。ide和 持续集成 服务器消耗的XM

    junit ant集成生成html,xml,文本结果

    junit 和ant 集成,,,生成的结果为xml,html,文本格式哦...

    AppFuse学习笔记(J2EE入门级框架)

    为了简化开发,预定义好了一套目录结构、基类、用来创建数据库、配置Tomcat、测试部署应用的 Ant 任务,帮助快速自动生成源程序和自动维护部分配置文件。 AppFuse2.0重构了AppFuse1.0,转到Maven2和Jdk1.5。

    appfuse 学习笔记

    为了简化开发,预定义好了一套目录结构、基类、用来创建数据库、配置Tomcat、测试部署应用的 Ant 任务,帮助快速自动生成源程序和自动维护部分配置文件。 AppFuse2.0重构了AppFuse1.0,转到Maven2和Jdk1.5。

    Hudson持续集成工具-其他

    4、生成JUnit/TestNG测试报告。 5、分布式构建支持-Hudson能够让多台计算机一起构建/测试。 6、文件识别- Hudson能够跟踪哪次构建生成哪些jar,哪次构建使用哪个版本的jar等。 7、插件支持-Hudson可以通过插件扩展,...

    Appfuse教程Appfuse开发.pdf

    用 户管理、根据不同的用户可以展现不同的菜单,可以自动生成40%-60%左右的代码,自带了默认的一些在CSS中设定的样式,使用这些样式能很快的改变整 个系统的外观,还有自动化测试的功能。  它最大的价值就是为我们...

    leetcode-leetcode-helper:节省您为每个leetcode问题构建脚手架的时间

    集成了Junit 4 、 log4j 、 slf4j 。 com.ciaoshen.leetcode.util包为TreeNode 、 ListNode等 7 种常用数据结构提供了最简单的实现。 配置问题 一行生成解决方案/测试框架的命令 生成的骨架: 单行推荐编译和运行 ...

    GretAnt-开源

    Gretant是将Gretel(负责覆盖率测量的工具)和ant集成在一起的工具。 这样就可以从ant运行测试(例如Junit测试用例),然后生成报告。

    iuhyiuhkjh908u0980

    IVY,它是一个管理(记录、跟踪、解析和报告)项目依赖的工具,可与ApacheAnt紧密集成,很多的信息,请参照: http://ant.apache.org/ivy 1.代码可以从这里得到 svn co ...

    leetcodejava常用-leetcode-helper:leetcode助手

    集成了Junit 4 、 log4j 、 slf4j 。 com.ciaoshen.leetcode.util包为TreeNode 、 ListNode等 7 种常用数据结构提供了最简单的实现。 配置问题 一行生成解决方案/测试框架的命令 生成的骨架: 单行推荐编译和运行 ...

    NextMock-开源

    NextMock生成Mock类以测试您的Java代码。 它将与JUnit,ANT和eclipse集成在一起,以提供良好的重构支持。 该项目目前处于Hibernate状态。 如果您想唤醒它,只需在邮件列表中与我们联系!

    北风客户关系管理源码 CRM

    经过厉老师2个多月的对原有项目的二次开发,重新集成了新技术点,使项目的价值远远超过实际开发项目的价值。 四、用到的框架和技术点: 1.struts2.0 2.Hibernate 3.spring 4.Ajax 5.Jfreechart 6.JQuery 7, JSP Tree...

    Java学习笔记-个人整理的

    \contentsline {chapter}{Contents}{2}{section*.1} {1}Java基础}{17}{chapter.1} {1.1}基本语法}{17}{section.1.1} {1.2}数字表达方式}{17}{section.1.2} {1.3}补码}{19}{section.1.3} {1.3.1}总结}{23}{...

Global site tag (gtag.js) - Google Analytics