问题描述
我正在使用Eclipse + Selenium WebDriver + TestNG
I m using Eclipse + Selenium WebDriver + TestNG
这是我的课程结构:
class1
{
@test (invocation count =4)
method1()
@test (invocation count =4)
method2()
}
我的testing.xml文件:
my testing.xml file :
<classes>
<class name="tests.class1">
<methods>
<include name="method1" />
<include name="method2" />
</methods>
</class>
</classes>
运行当前当前的testing.xml时,测试的顺序为:方法1方法1方法1方法1方法2方法2方法2方法2
When running through my current testing.xml, the order of the tests is:method1method1method1method1method2method2method2method2
但是我希望测试按以下顺序运行:方法1方法2方法1方法2方法1方法2方法1方法2
But I want the tests to be run in the following order:method1method2method1method2method1method2method1method2
请指导我获得所需的结果.非常感谢.
Please guide me to achieve the desired result.Thanks a lot.
推荐答案
您还可以将TestNG的优先级"用作:
You can also use "priority" of TestNG as:
@Test(priority = -19)
public void testMethod1(){
//some code
}
@Test(priority = -20)
public void testMethod2(){
//some code
}
[注意:此测试方法的优先级.优先级较低的将排在第一位]
[Note: The priority for this test method. Lower priorities will be scheduled first]
因此,在上面的示例中,testMethod2将首先以比-19少-20的方式执行
So, in the above example testMethod2 will be executed first as -20 less than -19
您可以访问以获取更多详细信息: http://testng.org/doc/documentation-main.html#annotations
You can visit for more details:http://testng.org/doc/documentation-main.html#annotations
这篇关于在TestNG中一个接一个地运行测试方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!