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. JS基础(四)运算符

    一.比较运算符 1.== : 判断两边值是否相等 2.>= : 判断左边的值是否大于或等于右边的值 3.<= : 判断左边边的值是否小于或等于右边的值 4.>   : 判断左边的值是 ...

  2. [转帖]SQLSERVER 使用触发器实现 禁用sa用户 在非本机登录

    原贴地址: https://blog.csdn.net/reblue520/article/details/51580102 具体的方法为: 创建一个触发器 CREATE TRIGGER forbid ...

  3. WebSocket 时时双向数据,前后端(聊天室)

    https://blog.csdn.net/lecepin/article/details/54632749 实例内容 今天主要说一下微信的WebSocket接口以及在小程序中的使用. WebSock ...

  4. javascript面向对象系列第五篇——拖拽的实现

    前面的话 在之前的博客中,拖拽的实现使用了面向过程的写法.本文将以面向对象的写法来实现拖拽 写法 <style> .test{height: 50px;width: 50px;backgr ...

  5. echarts实现环形图

    前端框架使用的angular,使用echarts实现环形图 1. item.component.html <div id="box1" class="pie&quo ...

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

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

  7. Problem C Dist 解题报告

    Problem C Dist Description 有一个\(n\)个点带边权的连通无向图,边集用\(k\)个集合\(s_1,s_2,\dots,s_k\)和\(k\)个整数\(w_1,w_2,\d ...

  8. 【CF61D】Eternal Victory

    题目大意:给定一棵 N 个节点的树,求从 1 号节点(根节点)出发,任意节点结束,且至少经过每个节点一次的最短路径是多少. 题解:首先考虑最终要回到根节点的情况,可以发现最短路径长度一定等于该树边权的 ...

  9. Andrew Ng机器学习课程,第一周作业,python版本

    Liner Regression 1.梯度下降算法 Cost Function 对其求导: theta更新函数: 代码如下: from numpy import * import numpy as n ...

  10. 使用 yield 减少内存消耗

    php 里面想要处理一个文本文件,有一个方法是使用 file() 函数,但是这个函数会读取文件所有内容,可能会导致占用很大内存. // 28.1 M 的文本文件, 200w 行 $file = 'st ...