如何根据条件禁用 TestNG 测试 [英] How to disable TestNG test based on a condition

查看:35
本文介绍了如何根据条件禁用 TestNG 测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前是否有一种方法可以根据条件禁用 TestNG 测试

Is there currently a way to disable TestNG test based on a condition

我知道您目前可以在 TestNG 中禁用测试:

I know you can currently disable test as so in TestNG:

@Test(enabled=false, group={"blah"})
public void testCurrency(){
...
}

我想根据条件禁用相同的测试,但不知道如何.像这样:

I will like to disable the same test based on a condition but dont know how. something Like this:

@Test(enabled={isUk() ? false : true), group={"blah"})
public void testCurrency(){
...
}

任何人都知道这是否可行.

Anyone has a clue on whether this is possible or not.

推荐答案

您有两个选择:

您的注释转换器将测试条件,然后在不满足条件时覆盖@Test 注释以添加属性enabled=false".

Your annotation transformer would test the condition and then override the @Test annotation to add the attribute "enabled=false" if the condition is not satisfied.

这篇关于如何根据条件禁用 TestNG 测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆