http://junit.sourceforge.net/javadoc/org/junit/runner/notification/RunListener.html

org.junit.runner.notification
Class RunListener

java.lang.Object   org.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);
}

最新文章

  1. MySQL源码分析:源码文件结构及主要数据结构
  2. sql 内连接和外链接
  3. The median of multi ascending array
  4. 当一个页面出现多个checkbox全选时的处理
  5. ajax、post、get实例
  6. 我写了一个java实体类,implements了Serializable接口,然后我如何让serialversionUID自动生成
  7. docker note
  8. Hacker(七)----黑客常用术语和DOS命令
  9. Java程序执行Linux命令
  10. MSSQL、C# 、Winform、ASP.NET - 数据库备份与还原模块
  11. 【Java】ArrayList 的 toArray() 方法抛出 ClassCastException 异常
  12. SVN常用命令积累
  13. cursor 属性
  14. Winsock编程基础1
  15. linux内存 free命令 buffer cache作用
  16. macOS上实现Qt应用程序做文件关联打开
  17. python类之魔法方法
  18. Linux内核分析第二次作业
  19. 【转载】selenium与自动化测试成神之路
  20. deeplearningbook-chinese

热门文章

  1. LLVM4.0与3.5编译phase对比
  2. JS实现table表格在鼠标移动出现一行变色或者十字叉变色
  3. Jdk1.8的安装(Linux和windows)
  4. 02-springmvc分布式项目dataService项目配置
  5. Gym - 102040B Counting Inversion (数位dp)
  6. Windows 和 Linux 下生成以当前时间命名的文件
  7. 【leetcode】1259.Handshakes That Don't Cross
  8. chromedriver.exe,自动化web, 安装谷歌驱动,以及可能遇到的坑
  9. vue-cli中route和router的区别
  10. JavaWeb_Ajax通过JQuery和原生js异步传输数据