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之间的协作应用的是 ...
随机推荐
- eclipses配置tomcat
1,项目右键属性,设置为1.8,与jdk相对应 2,自动发布,tomcat 3,使用自己的tomcat 4,
- 颜色框架Hue使用方法
Hue地址 如果有疑问或者想探讨iOS开发相关的技术,十分欢迎. 1. cocoapods安装Hue pod "Hue" 2. 导入框架 import Hue 3. 将十六进制数字 ...
- 从FBV到CBV一(开始)
span::selection, .CodeMirror-line > span > span::selection { background: #d7d4f0; }.CodeMirror ...
- Linux 配置:Xmanager连接Linux图形界面
想要在远程终端使用用图形界面来操作和控制Linux服务器,就在windows下像使用MSTSC一样.linux通过XDMCP来提供这种支持,我们只要用一个终端仿真软件如:xmanager就可以实现,但 ...
- 【转】Java的四种代码块
原贴地址:http://www.cnblogs.com/end/archive/2012/12/21/2827554.html 一.普通代码块 直接在一个方法中出现的{}就称为普通代码块,例子程序如下 ...
- 局部处理的边缘连接(python+opencv)
rt import cv2 import numpy as np path = "_lo.png" img = cv2.imread(path) gray = cv2.cvtCol ...
- UVALive - 5695 The Last Puzzle (思维+区间dp)
题目链接 题目大意:有n个按钮排成一条直线,你的任务是通过左右移动按下所有按钮,按钮如果一段时间没有被按下就会被弹开. 以下是我的推论(不一定正确): 直观地看的话,如果选择的是最优路径,那么路径的形 ...
- 一分钟 解决Tomcat端口 占用问题
打开 cmd命令 在 命令界面中输入 netstat -ano|findstr 8080 使用 命令 taskill /pid 端口号 /f 结束占用
- GridView设置右键菜单
一.控件设定: 1.页面添加ContextMenuStrip控件: 2.ContextMenuStrip添加菜单项: 3.gridControl找到ContextMenuStrip属性,设置成刚添加C ...
- 科普TPF知识
https://tieba.baidu.com/p/4926092734?see_lz=1&pn=1 707680700 https://tieba.baidu.com/p/492609273 ...
org.junit.runner.notification.RunListener