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自身无失败重试机制,可以 ...
随机推荐
- servlet编码乱码问题
继承HttpServlet 重写doGet(HttpServletRequest req,HttpServletResponse resp),doPost()方法 post提交时: protected ...
- 获取select的 text
JS获取select的value和text值的简单实例 感谢 3lian8 的投递 时间:2014-02-27 来源:三联教程 本篇文章主要是对JS获取select的value和text值的简单实例进 ...
- 插入排序的C、C++实现
一.插入排序 有一个已经有序的数据序列,要求在这个已经排好的数据序列中插入一个数,但要求插入后此数据序列仍然有序,这个时候就要用到一种新的排序方法--插入排序法,插入排序的基本操作就是将一个数据插入到 ...
- Struts2 分割字符串标签s:generator
有些时候会从后台返回一个字符串,可以通过Strut2的标签s:generator进行分割. generator标签,该标签可以将指定字符串按指定分隔符分割成多个字串.生成的多个字串可以用iterato ...
- github如何添加新的分支
需求:甲建立分支分给乙步骤:在甲创建的项目仓库里边点右上角的按钮 就可以通过名字搜索了. 在乙的右上角 再选中Repositories就可以看到所有的 存储库 了
- Linux上case用法
Linux上case用法示例: #!/bin/bash # This is a script for test case ASK_COUNT=$ #从参数获取该变量的值 # if [ -z " ...
- Centos 搭建 http服务器
1,安装 yum install httpd 2,查看是否安装成功 netstat [root@localhost ~]# netstat -anp | grep 80 tcp 0 0 :: ...
- 第一节 Spring的环境搭建
正在构建,扫一扫,敬请期待 和玩得来的人在一起玩才叫玩! 和玩不来的人在一起玩,那种感觉就像加班啊! 关注胖个人微信公众账号,希望对各位学生有所帮助! --胖先生 Spring框架,什么是Sprin ...
- SQL中的全局变量和局部变量(@@/@)
在SQL中,我们常常使用临时表来存储临时结果,对于结果是一个集合的情况,这种方法非常实用,但当结果仅仅是一个数据或者是几个数据时,还要去建一个表,显得就比较麻烦,另外,当一个SQL语句中的某些元素经常 ...
- Internet Explorer 6 的15个讨厌的bug和简单的解决方法
关于bug更全的,我推荐去这个网站hasLayout,整理的非常全!三年前就看了,最近手生,又翻出来看看~~虽然上面有很多bug讲解,但是我觉得目前用的比较多或者说是常见的应该属下面这篇文章,15 a ...