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 ...
随机推荐
- maven项目下tomcat直接启动不了(LifecycleException)。报错如下截图
经查,tomcat项目下的lib中没有jar包,发布的时候没有将jar包发布上去.这个问题在我的博客中以前遇到过.如何将maven的jar发布到项目中,我的博客里面有记载
- mysql出现的错误
(一)ERROR 1005 (HY000): Can't create table '.\day19\user_role.frm' (errno: 121) 今天遇到的这个问题是因为创建了五张表,其中 ...
- angularjs 利用filter进行表单查询及分页查询
页面: <div> <input style="width:90%;margin-left:5px;margin-right:5px;" class=" ...
- c#wiform中KeyDown事件
当首次按下键盘上某个键时发生事件. 例如 private void Form1_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Ke ...
- angular.js 字符串1
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script sr ...
- Ubuntu Apache 伪静态配置 url重写 步骤
1.加载rewrite模块sudo ln -s /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled/rewrite.l ...
- Fedora 21 安装Infinality
原文地址: Fedora 21 用infinality美化你的字体 http://blog.csdn.net/element207/article/details/41746683 安装infinal ...
- Unity3D动态加载外部资源
最近一直在和这些内容纠缠,把心得和大家共享一下: Unity里有两种动态加载机制:一是Resources.Load,一是通过AssetBundle,其实两者本质上我理解没有什么区别.Resources ...
- 使用php实现爬虫程序 套取网站的图片实例
<?php //去采集a67 图片 网站链接 http://www.xiamov.com/list/1/p.2 你也可以采集其他网站的图片 //创建链接 dedecms--a67 //设置执行不 ...
- ajax验证用户名和密码
var user = form.name.value; var password = form.password.value; var url = "chkname.php?user=&qu ...