在TestNG中一个接一个地运行测试方法 [英] Running test methods one after another in TestNG

查看:59
本文介绍了在TestNG中一个接一个地运行测试方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用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: method1 method1 method1 method1 method2 method2 method2 method2

但是我希望测试按以下顺序运行: 方法1 方法2 方法1 方法2 方法1 方法2 方法1 方法2

But I want the tests to be run in the following order: method1 method2 method1 method2 method1 method2 method1 method2

请指导我获得所需的结果. 非常感谢.

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中一个接一个地运行测试方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆