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运行失败,继续执行的更多相关文章

  1. TestNG监听器实现用例运行失败自动截图、重运行功能

    注: 以下内容引自 http://blog.csdn.net/sunnyyou2011/article/details/45894089 (此非原出处,亦为转载,但博主未注明原出处) 使用Testng ...

  2. TestNG实现用例运行失败自动截图(转载)

    转载自:https://blog.csdn.net/galen2016/article/details/70193684 重写Listener的onTestFailure方法 package com. ...

  3. TestNG简单的学习-TestNG运行

    转载:http://topmanopensource.iteye.com/blog/1983735 TestNG简单的学习-TestNG运行 文档来自官方地址: http://testng.org/d ...

  4. testng testcase失败重试

    简单介绍 需求场景:测试移动端应用,常会因为点击失效.网络延迟大等原因导致测试脚本失败.这时,需要自动重新运行失败的脚本,直到脚本成功通过或者到达限定重试次数. 解决方案:实现testng的IRetr ...

  5. testng跑失败用例重试

    testng 提高用例通过率,失败用例要重新运行一次 步骤: 1.新建一个Retry 类,implements IRetryAnalyzer接口,这个类里面确定重跑次数,以及分析每次失败是否需要重新运 ...

  6. testng增加失败重跑机制

    注: 以下内容引自 http://www.yeetrack.com/?p=1015 testng增加失败重跑机制 Posted on 2014 年 10 月 31 日 使用Testng框架搭建自动测试 ...

  7. Maven捆绑TestNG实现测试自动化执行、部署和调度

    一. 需求介绍 自动化测试,尤其是接口测试时,要写大量的测试用例,这些测试用例我们当然首选使用TesteNG编写,用例数量大,还涉及各种依赖包之类的问题,因此用Maven管理也是最方便最易实现的. 面 ...

  8. python unittest套件,修改为失败重新执行

    #套件,修改为失败重新执行 import time import unittest from unittest.suite import _isnotsuite class Suit(unittest ...

  9. python unittest case运行失败重试

    因为使用unittest进行管理case的运行.有时case因为偶然因素,会随机的失败.通过重试机制能够补充保持case的稳定性.查阅资料后发现,python的unittest自身无失败重试机制,可以 ...

随机推荐

  1. Beta阶段敏捷冲刺①

    1.提供当天站立式会议照片一张. 每个人的工作 (有work item 的ID),并将其记录在码云项目管理中: 1.1昨天已完成的工作. 姓名 昨天已完成的工作 徐璐琳 熟悉"慧记" ...

  2. PAT 1043 输出PATest

    https://pintia.cn/problem-sets/994805260223102976/problems/994805280074743808 给定一个长度不超过10000的.仅由英文字母 ...

  3. linux客户端WinSCP

    WinSCP是一个Windows环境下使用SSH的开源图形化SFTP客户端.同时支持SCP协议.它的主要功能就是在本地与远程计算机间安全的复制文件.   这是一个中文版的介绍.从这里链接出去的大多数文 ...

  4. LOJ#6118 鬼牌

    \(\rm upd\):是我假了...这题没有爆精...大家要记得这道题是相对误差\(10^{-6}\)...感谢@foreverlasting的指正. 题是好题,可是标算爆精是怎么回事...要写的和 ...

  5. The Two Routes CodeForces - 601A(水最短路)

    一个完全图 1和n肯定有一条路  不是公路就是铁路  另= 另一个跑遍最短路即可 #include <bits/stdc++.h> #define mem(a, b) memset(a, ...

  6. HGOI2010816 (NOIP 提高组模拟赛 day1)

    Day1 210pts(含T1莫名的-10pts和T3莫名的-30pts) 100+70+40=210 rank 29 这道题第一眼看是字符串匹配问题什么KMP啊,又想KMP不会做啊,那就RK Has ...

  7. 纯干货!一款APP从设计稿到切图过程全方位揭秘(转)

    @BAT_LCK :我本身是一名GUI设计师,所以我只站在GUI设计师的角度去把APP从项目启动到切片输出的过程写一写,相当于工作流程的介绍吧.公司不同,流程不尽相同,但是终究还是能有些帮助. 依旧声 ...

  8. Python内置模块-日志模块(logging)常见用法

    Python内置模块-日志模块(logging)常见用法 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.初识logging模块 #!/usr/bin/env python #_ ...

  9. [Spring] 学习Spring Boot之二:整合MyBatis并使用@Trasactional管理事务

    一.配置及准备工作 1.在 Maven 的 pom 文件中新增以下依赖: <dependency> <groupId>mysql</groupId> <art ...

  10. JDBC编程示例

    package com.lovo.test; import java.sql.Connection;import java.sql.DriverManager;import java.sql.SQLE ...