Junit : how to add listener, and how to extends RunListener to override behaviors while failed
org.junit.runner.notification 
 Class RunListener
java.lang.Objectorg.junit.runner.notification.RunListener
- 
public class RunListener 
- extends java.lang.Object
If you need to respond to the events during a test run, extend RunListener  and override the appropriate methods. If a listener throws an exception while processing a   test event, it will be removed for the remainder of the test run.
For example, suppose you have a Cowbell  class that you want to make a noise whenever a test fails. You could write:
public class RingingListener extends RunListener {
public void testFailure(Failure failure) {
Cowbell.ring();
}
}
To invoke your listener, you need to run your tests through JUnitCore.
public void main(String... args) {
JUnitCore core= new JUnitCore();
core.addListener(new RingingListener());
core.run(MyTestClass.class);
}
Junit : how to add listener, and how to extends RunListener to override behaviors while failed的更多相关文章
- win10系统在执行“ vagrant box add centos7 vagrant-centos-7.box”添加box时,报错“Vagrant failed to initialize at a very early stage:  Failed to locate the powershell executable on the available PATH. ”
		这个意思是:在有效的路径中未能执行PowerShell命令. 请检查PowerShell的安装和有效的路径,然后再尝试重新运行这个命令. 在环境变量path中添加powershell的路径,例如:C: ... 
- android ListView 可缩放,支持左右上下手势
		public class ZoomListView extends ListView implements SwipeListener { public static enum Action { Le ... 
- java 实现自定义事件
		import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; i ... 
- Netty学习笔记(二)——netty组件及其用法
		1.Netty是 一个异步事件驱动的网络应用程序框架,用于快速开发可维护的高性能协议服务器和客户端. 原生NIO存在的问题 1) NIO的类库和API繁杂,使用麻烦:需要熟练掌握Selector.Se ... 
- How to use Junit Listener
		JUnit Listeners If you want to do some operations when your tests are started, passed, finished, fai ... 
- 获取JUnit的执行结果
		junit执行之后会有一个结果展示,下面就来看一下怎么获取这些结果并将其存储为一个对象 junit代码如下: package test; import org.junit.After; import ... 
- junit源码解析--测试驱动运行阶段
		前面的博客里面我们已经整理了junit的初始化阶段,接下来就是junit的测试驱动运行阶段,也就是运行所有的testXXX方法.OK,现在我们开始吧. 前面初始化junit之后,开始执行doRun方法 ... 
- junit源码解析--核心类
		JUnit 的概念及用途 JUnit 是由 Erich Gamma 和 Kent Beck 编写的一个开源的单元测试框架.它属于白盒测试,只要将待测类继承 TestCase 类,就可以利用 JUnit ... 
- JUnit源码分析 - 扩展 - 自定义RunListener
		RunListener简述 JUnit4中的RunListener类用来监听测试执行的各个阶段,由RunNotifier通知测试去运行.RunListener与RunNotifier之间的协作应用的是 ... 
随机推荐
- dubbo学习笔记二(服务调用)
			项目结构 代码示例 由于之前的IEchoService 的一个方法只是在服务端控制台打印,不便在浏览器测试,所以新添加的方法 api和服务端代码变更 public interface IEchoSer ... 
- Spring 资源加载
			pom.xml ``` org.springframework spring-core 4.3.14.RELEASE org.springframework spring-beans 4.3.16.R ... 
- ArcEngine介绍
			一.ArcEngine简介ArcEngine被定位为一个嵌入式的产品,它并非面向最终用户,而是一个面向开发者的产品.对于繁冗的GIS开发工作而言,理想的解决方案是一个基于组件的实用的开发框架,且该框架 ... 
- Linux驱动开发之字符设备驱动模型之file_operations
			90%的驱动模型都是按照下图开发的 下面来说下设备描述结构是什么东西 打开Linux-2.6.32.2的Source Insight 工程,搜索cdev 比如一个应用程序需要调用read和write这 ... 
- 09Cookie&Session
			1.会话技术 1. 会话:一次会话中包含多次请求和响应. 一次会话:浏览器第一次给服务器资源发送请求,会话建立,直到有一方断开为止2. 功能:在一次会话的范围内的多次请求间,共享数据3. 方式: 1 ... 
- 第10课:[实战] Redis 网络通信模块源码分析(3)
			redis-server 接收到客户端的第一条命令 redis-cli 给 redis-server 发送的第一条数据是 *1\r\n\$7\r\nCOMMAND\r\n .我们来看下对于这条数据如何 ... 
- [转帖]微軟将从 .NET 4 以后的版本弃用 System.Data.OracleClient
			转帖--微軟将从 .NET 4 以后的版本弃用 System.Data.OracleClient Posted on -- : eaglet 阅读() 评论() 编辑 收藏 原贴 http://www ... 
- java内存泄漏与处理
			内存溢出 out of memory,是指程序在申请内存时,没有足够的内存空间供其使用,出现out of memory: 内存泄露 memory leak,是指程序在申请内存后,无法释放已申请的内存空 ... 
- Redis 管道pipeline
			Redis是一个cs模式的tcp server,使用和http类似的请求响应协议. 一个client可以通过一个socket连接发起多个请求命令. 每个请求命令发出后client通常会阻塞并等待red ... 
- SpringMVC优雅的获取HttpSevletRequest及HttpServletResponse简录
			https://cloud.tencent.com/developer/article/1403947 通常情况下,SpringMVC可以通过入参的方式绑定HttpServletRequest和Htt ... 
