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. 随web应用启动而自启动的后台线程

    当前遇到一个需求: 需要在web应用启动的时候就启动一个线程定时的来做某项工作. 有两种解决方法: 1.增加一个监听器Listener来实现相关功能. 2.增加一个随项目启动的servlet来实现相关 ...

  2. Tomcat Jboss Apache WebLogic区别与比较(阿里面试)

    1. Tomcat是Apache鼎力支持的Java Web应用服务器,只能做JSP和Servlet的Container,不支持EJB,由于它优秀的稳定性以及丰富的文档资料,广泛的使用人群,从而在开源领 ...

  3. js写插件教程深入

    原文地址:https://github.com/lianxiaozhuang/blog 转载请注明出处 js 写插件教程深入 1.介绍具有安全作用域的构造函数 function Fn(name){ t ...

  4. 小菜菜mysql练习解读分析1——查询" 01 "课程比" 02 "课程成绩高的学生的信息及课程分数

    查询" 01 "课程比" 02 "课程成绩高的学生的信息及课程分数 好的,第一道题,刚开始做,就栽了个跟头,爽歪歪,至于怎么栽跟头的 ——需要分析题目,查询的是 ...

  5. SSM 项目搭建 (IDEA)

    好好想了想,还是准备给大家发一个简单的SSM的项目搭建教程. 我觉得通常来说,只是XML的配置文件可能让人头痛了点,其他的倒真不是问题. 不过话说回来,mybatis一直让我觉得用起来不方便.因为数据 ...

  6. 【BZOJ1485】[HNOI2009]有趣的数列(组合数学)

    [BZOJ1485][HNOI2009]有趣的数列(组合数学) 题面 BZOJ 洛谷 题解 从小往大填数,要么填在最小的奇数位置,要么填在最小的偶数位置. 偶数位置填的数的个数不能超过奇数位置填的数的 ...

  7. 利用scrapy_redis实现分布式爬虫

    介绍 Scrapy框架不支持分布式,所以需要将一些关键代码进行修改使之支持分布式.scrapy-redis相当于一个插件,用来替换scrapy中的一些模块,使得scrapy支持分布式.github地址 ...

  8. C# 获取IIS站点及虚拟目录信息

    using System; using System.DirectoryServices; using System.Collections.Generic; using System.Text; n ...

  9. jq禁用html标签

    原文:http://www.jb51.net/article/105154.htm 移除或禁用html元素的点击事件可以通过css实现也可以通过js或jQuery实现. 一.CSS方法 .disabl ...

  10. adb相关基础知识集锦

    Android单元测试adb shell am instrument -w adb shell dumpsys adb logcat介绍