我在gradle上做了一个简单的测试。登录和四个功能:
此外,这些测试中的四个应该从某个页面开始。我找不到正确的TestNG.xml
文件。
public class Test {
@Test(groups = {"T1"}
public void login() {}
@Test(dependsOnGroups = "T1", groups = {"T3"})
public void change_name(){}
@Test(dependsOnGroups = "T1", groups = {"T3"})
public void send_massage(){}
@Test(dependsOnGroups = "T1", groups = {"T3"})
public void find_my_massages(){}
@Test(dependsOnGroups = "T1", groups = {"T3"})
public void change_language(){}
}`
我的TestNG
<suite name="TestYa" parallel="methods">
<test name="Test1 ">
<groups>
<run>
<include name="T1"/>
<include name="T3"/>
</run>
</groups>
<classes>
<class name="Test">
<methods>
<include name="find_my_massages"/>
</methods>
</class>
</classes>
</test>
答案 0 :(得分:1)
您可以通过以下方式在TestNG.XML中进行处理:
TestNG.XML:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite">
<test thread-count="5" name="Test">
<classes>
<class name="packageName.className(Test)"/>
</classes>
</test> <!-- Test -->
</suite> <!-- Suite -->
@测试:-
public class Test {
@Test(groups = {"T1"}, priority=1)
public void login() {}
@Test(priority=2)
public void change_name(){}
@Test(priority=3)
public void send_massage(){}
@Test(priority=4)
public void find_my_massages(){}
@Test(priority=5)
public void change_language(){}
}`
像这样,您可以定义@Test的优先级,按照定义的顺序执行