testng运行失败,继续执行
1.重写断言类
public class Verify {
public static StringBuffer verificationErrors= new StringBuffer();;
public static void verifyTrue(boolean o) {
try {
Assert.assertTrue(o);
} catch (Error e) {
verificationErrors.append(e.toString());
}
}
public static void verifyFalse(boolean o) {
try {
Assert.assertFalse(o);
} catch (Error e) {
verificationErrors.append(e.toString());
}
}
public static void verifyEquals(Object expected, Object actuals) {
try {
Assert.assertEquals(expected, actuals);
} catch (Error e) {
verificationErrors.append(e.toString());
}
}
public static void verifyEquals(Object expected, Object actuals,
String message) {
try {
Assert.assertEquals(expected, actuals, message);
} catch (Error e) {
verificationErrors.append(e.toString());
}
}
public static void assertEquals(String actual, String expected,
String message) {
try {
Assert.assertEquals( actual, expected, message);
} catch (Error e) {
verificationErrors.append(e.toString());
}
}
public static void assertEquals(String actual, String expected) {
try {
Assert.assertEquals( actual, expected);
} catch (Error e) {
verificationErrors.append(e.toString());
}
}
public static void tearDown() {
String verificationErrorString = verificationErrors.toString();
if (!"".equals(verificationErrorString)) {
Assert.fail(verificationErrorString);
}
}
}
2.编写监听断言类
public class ListenerVerify implements IInvokedMethodListener {
@Override
public void afterInvocation(IInvokedMethod method, ITestResult testResult) {
// TODO Auto-generated method stub
if (method.isTestMethod()) {
Verify.tearDown();
}
}
@Override
public void beforeInvocation(IInvokedMethod method, ITestResult testResult) {
// TODO Auto-generated method stub
}
}
3.测试类
@Listeners( {ListenerVerify.class})
public class TestVerify {
@Test
public void test(){
Verify.assertEquals("1", "1");
Verify.assertEquals("1", "2");
Verify.assertEquals("1", "3");
}
}
结果如下

testng运行失败,继续执行的更多相关文章
- TestNG监听器实现用例运行失败自动截图、重运行功能
注: 以下内容引自 http://blog.csdn.net/sunnyyou2011/article/details/45894089 (此非原出处,亦为转载,但博主未注明原出处) 使用Testng ...
- TestNG实现用例运行失败自动截图(转载)
转载自:https://blog.csdn.net/galen2016/article/details/70193684 重写Listener的onTestFailure方法 package com. ...
- TestNG简单的学习-TestNG运行
转载:http://topmanopensource.iteye.com/blog/1983735 TestNG简单的学习-TestNG运行 文档来自官方地址: http://testng.org/d ...
- testng testcase失败重试
简单介绍 需求场景:测试移动端应用,常会因为点击失效.网络延迟大等原因导致测试脚本失败.这时,需要自动重新运行失败的脚本,直到脚本成功通过或者到达限定重试次数. 解决方案:实现testng的IRetr ...
- testng跑失败用例重试
testng 提高用例通过率,失败用例要重新运行一次 步骤: 1.新建一个Retry 类,implements IRetryAnalyzer接口,这个类里面确定重跑次数,以及分析每次失败是否需要重新运 ...
- testng增加失败重跑机制
注: 以下内容引自 http://www.yeetrack.com/?p=1015 testng增加失败重跑机制 Posted on 2014 年 10 月 31 日 使用Testng框架搭建自动测试 ...
- Maven捆绑TestNG实现测试自动化执行、部署和调度
一. 需求介绍 自动化测试,尤其是接口测试时,要写大量的测试用例,这些测试用例我们当然首选使用TesteNG编写,用例数量大,还涉及各种依赖包之类的问题,因此用Maven管理也是最方便最易实现的. 面 ...
- python unittest套件,修改为失败重新执行
#套件,修改为失败重新执行 import time import unittest from unittest.suite import _isnotsuite class Suit(unittest ...
- python unittest case运行失败重试
因为使用unittest进行管理case的运行.有时case因为偶然因素,会随机的失败.通过重试机制能够补充保持case的稳定性.查阅资料后发现,python的unittest自身无失败重试机制,可以 ...
随机推荐
- C#简述(一)
详情请参考:http://www.runoob.com/csharp/csharp-tutorial.html 1.C# 是一个简单的.现代的.通用的.面向对象的编程语言,它是由微软(Microsof ...
- Rendertron:谷歌 Chrome 新的 headless 模式又贡献了一个新的技巧
摘自:https://zhuanlan.zhihu.com/p/31670033 Rendertron:JavaScript Web 富应用的一个老问题是如何使这些页面的动态渲染部分可供搜索引擎检索. ...
- layout图形化界面看不到内容 Failed to find the style corresponding to the id
1.问题 在创建新的工程的时候,选择目标SDK为api21,编译SDK为api23.创建出来的layout文件图形化界面中看不到,并且报错: Failed to find the style corr ...
- idea中添加类和方法注释以及codeCheck
前言:在idea中我们添加类以及类的方法的注释很有必要,让其他人能够看懂这个类或者函数的作用是什么:为了在开发过程中检查自己的编程规范,可以通过codecheck工具进行自我检查和约束 一.在idea ...
- SQLServer将一个表的数据导入到另一个表
1.假如A表存在 insert into A(a,b,c) (select a,b,c from B) 2.假如A表不存在 select a,b,c into A from B 3.假如需要跨数据库 ...
- TCP协议 连接三次握手
TCP(Transmission Control Protocol) 传输控制协议 TCP是主机对主机层的传输控制协议,提供可靠的连接服务,采用三次握手确认建立一个连接: 位码即tcp标志位,有6种标 ...
- 洛谷P4180 [BJWC2010]次小生成树(最小生成树,LCT,主席树,倍增LCA,倍增,树链剖分)
洛谷题目传送门 %%%TPLY巨佬和ysner巨佬%%% 他们的题解 思路分析 具体思路都在各位巨佬的题解中.这题做法挺多的,我就不对每个都详细讲了,泛泛而谈吧. 大多数算法都要用kruskal把最小 ...
- 【hdu3709】 Balanced Number
http://acm.hdu.edu.cn/showproblem.php?pid=3709 (题目链接) 题意 求范围${[a,b]}$之间的平衡数的个数,所谓平衡数就是以某一位为支点,两侧的力矩相 ...
- [SCOI2014]方伯伯的商场之旅
Description 方伯伯有一天去参加一个商场举办的游戏.商场派了一些工作人员排成一行.每个人面前有几堆石子.说来也巧,位置在 i 的人面前的第 j 堆的石子的数量,刚好是 i 写成 K 进制后的 ...
- Openstack 错误日志查看方法
openstack错误日志查看方法 https://blog.csdn.net/ZanShichun/article/details/72672945