如果我们有<include name="web" >
和<include name="weekend" >
,TestNG会运行属于网络或周末的所有方法。
是否可以更改此行为,以便TestNG运行属于web 和周末的所有方法?有谁知道这样做的方法?
答案 0 :(得分:2)
我找到了解决方案。
我使用beanshell来编写<method-selector>
标记内的条件。
类似的东西:
<method-selectors>
<method-selector>
<script language="beanshell"><![CDATA[
(groups.containsKey(FIRST_GROUP) && groups.containsKey(SECOND_GROUP))
]]>
</script>
</method-selector>
</method-selectors>
答案 1 :(得分:2)
是的,BeanShell是一种方法。
如果您需要更复杂的东西,可以使用IMethodInterceptor,它基本上允许您在TestNG开始处理它们之前重新排序所有测试方法。
以下是一个例子:
http://beust.com/weblog/2008/03/29/test-method-priorities-in-testng/