如何根据条件禁用testng测试 [英] How to disable testng test based on a condition
本文介绍了如何根据条件禁用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.
推荐答案
你有两个选择:
- Implement an annotation transformer.
- Use BeanShell.
您的注解变换器将测试该条件,然后覆盖@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屋!
查看全文