Timeout for tests
如果想把timeout太久的测试自动标记为失败,有两种方法:
1.在 @Test里加上 Timeout 参数
定义"timeout=1000“的话,如果超过1000 毫秒,failure会被一个抛出的异常触发。
import static org.junit.Assert.*;
import org.junit.Test; public class TimeoutTest { @Test(timeout=1000)
public void test(){
assertTrue("it should be true",true);
}
}
2.定义Timeout 规则(应用于整个测试类)
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.Timeout; public class Timeout2 {
public static String log; @Rule
public Timeout globalTimeout=new Timeout(10000); @Test
public void test01(){
log +="ran1";
for(;;){}
} @Test
public void test02(){
log+="ran2";
for(;;){}
}
}
Timeout for tests的更多相关文章
- Rules
我们之前处理异常的时候用到过Rules,当然还有很多其他规则.Rules允许弹性的添加或者重定义测试方法的行为.测试者可以重复使用或者扩展下面的某一个Rules,也可以写一个属于自己的规则. 这里先展 ...
- JUnit4单元测试基础篇
引言 JUnit作为Java语言的测试框架,在测试驱动开发(TDD)下扮演重要的角色.众所周知,无论开发大型项目还是一般的小型项目, 单元测试都至关重要.单元测试为软件可发测试维护提供了很大的便利.J ...
- Nodejs开源项目里怎么样写测试、CI和代码测试覆盖率
测试 目前主流的就bdd和tdd,自己查一下差异 推荐 mocha和tape 另外Jasmine也挺有名,angularjs用它,不过挺麻烦的,还有一个选择是qunit,最初是为jquery测试写的, ...
- JAVA自动化之Junit单元测试框架详解
一.JUnit概述&配置 1.Junit是什么? Junit是一个Java 编程语言的开源测试框架,用于编写和运行测试.官网 地址:https://junit.org/junit4/ 2.Ma ...
- 【转】CTS tests 4.2_r4
原文网址:http://www.xuebuyuan.com/1722006.html Precondition: 1.Get android sdk 2.Set adb to environment ...
- angular : $eval & $timeout
$digest: function() { var watch, value, last, watchers, length, dirty, ttl = TTL, next, current, tar ...
- Selenium 15: How to Run Parallel Tests Using Selenium Grid and JUnit
In this post, I will give two techniques and describe how to run your selenium tests in parallel by ...
- Timeout watchdog using a standby thread
http://codereview.stackexchange.com/questions/84697/timeout-watchdog-using-a-standby-thread he simpl ...
- iOS Automated Tests with UIAutomation
参照:http://blog.manbolo.com/2012/04/08/ios-automated-tests-with-uiautomation#1 UI Automation JavaScri ...
随机推荐
- angularjs modal 嵌套modal的问题
anguarjs中当遇到modal嵌套modal的时候,比如一个modal弹出啦一个modal1,关闭modal1后,modal本身的关闭功能失效,那么需要$modal来生命弹出的modal1并且关闭 ...
- 借用Toad 生成表空间的使用量图示
图示产生方法 图示(tablespace uage)如下
- power desinger 学习笔记<八>
转-PowerDesigner 把Comment复制到name中和把name复制到Comment 在使用PowerDesigner对数据库进行概念模型和物理模型设计时,一般在NAME或Comment中 ...
- 【转】 CoreGraphics QuartzCore CGContextTranslateCTM 用法
原文:http://blog.csdn.net/sqc3375177/article/details/25708447 CoreGraphics.h 一些常用旋转常量 #define M_E 2.71 ...
- JS入门笔记
DOM有四种节点: 1. 元素节点:即标签2. 属性节点:写在标签里的属性3. 文本节点:嵌在元素节点里展示出来的文本4. 文档节点:document 获取元素节点的三种常用方法: 1.ById 2. ...
- JavaMail API 1.4.7邮件发送
下载oracle javaMail API: http://www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive- ...
- ARM平台的内核模块编写与安装
Linux 系统一直在不断地发展,而相应地她的代码量也在不断的增大,直接导致的结果就是她的可执行镜像就变得越来越庞大.那么问题来了,如果将所有的镜像文件一次性地复制到内存中,那么所需的空间就非常 ...
- 解决IE6不支持position:fixed;的问题
在网页设计中,时常要用到把某个元素始终定位在屏幕上,即使滚动浏览器窗口也不会发生变化. 一般我们会使用position:fixed来进行绝对固定,但IE6并不支持position:fixed属性,所以 ...
- 通过C# 打开一个应用程序
System.Diagnostics.ProcessStartInfo Info = new System.Diagnostics.ProcessStartInfo(); //设置外部程序名 Info ...
- angular 实现总价满100折扣
<div ng-controller="CartController"> <div ng-repeat="item in items"> ...