运行 testNG 测试基于 "priority" 个测试用例

Run testNG tests based on "priority" of test cases

是否可以运行 TestNG 测试基于优先级?例如,假设我只想 运行 具有 priority=1.

的测试
<testng outputDir="${report.dir}" haltOnFailure="true" groups="${groups}">

    <!-- Extra project classpath-->
    <!-- Tell Ant where is the project and test classes -->
   <classpath refid="selenium.classpath" />
   <classpath refid="dynamicreports.classpath" />   


    <!-- Tell Ant what test classes need to run -->
    <classfileset dir="${bin.dir}" includes="**/*.class" />

</testng>

您可以让群组为您做这件事。根据优先级为测试用例分配一个组,运行 只有那个组

http://testng.org/doc/documentation-main.html#test-groups

是的,您可以使用 TestNG XML 套件定义中的 BeanShell 脚本来完成。类似于:

<method-selector>
    <script language="beanshell">
        <![CDATA[ testngMethod.getPriority() > 1 ]]>
    </script>
</method-selector>

有关详细信息,请参阅 http://testng.org/doc/documentation-main.html#beanshell