我知道下面的脚本可以包含几个组名。
<method-selectors>
<method-selector>
<script language="beanshell"><![CDATA[
groupNamesToRun = System.getProperty("groupToRun");
if ((groupNamesToRun == null) || (groupNamesToRun == "")) {
return true;
}
else
{
StringTokenizer groupsList = new StringTokenizer(groupNamesToRun, ",");
while (groupsList.hasMoreTokens()) {
if (groups.containsKey(groupsList.nextToken()))
return true;
}
return false;
}
}
]]>
</script>
</method-selector>
</method-selectors>
尽管如此,以下脚本可排除一些方法名称。
<method-selectors>
<method-selector>
<script language="beanshell">
<![CDATA[
methodPattern = "method1,method2";
if ((methodPattern == null) || (methodPattern == "")) {
return true;
}
else
{
StringTokenizer methodsList = new StringTokenizer(methodPattern, ",");
while (methodsList.hasMoreTokens()) {
methodName = methodsList.nextToken();
if (testngMethod.getMethodName().contains(methodName))
return false;
}
return true;
}
}
]]>
</script>
</method-selector>
</method-selectors>
但是,我发现很难实现Bean Shell脚本以包含很少的组名并排除很少的方法名。
以类似的方式,还需要以下组合的脚本。