This is related to the question How to create own annotation for junit that will skip test if concrete exception was thrown during execution?, but for TestNG.
我寻求一种解决方案来配置TestNG集成测试,以便在已知的基础结构异常列表中跳过(而不是失败),这些异常可能会偶尔出现 .
浏览TestNG代码后,我了解到使用 IHookable
或其他侦听器无法实现这一点 . TestNG也没有't have anything similar to JUnit'对象 . 此外,使用所有基础结构例外来扩展TestNG的 SkipException
对我来说不是一个选择 .
我错过了什么?
1 回答
实现IInvokedMethodListener并在afterInvocation方法中执行类似的操作
在testng.xml中设置此侦听器,或者基于您正在执行测试 .