如果不指定測(cè)試用例的執(zhí)行順序,默認(rèn)是按字典的順序執(zhí)行。如果要指定執(zhí)行的順序,可以通過(guò)testng.xml文件來(lái)指定。
<?xml version="1.0" encoding="UTF-8"?>
<suite name="Suite" parallel="false">
<test name="Demo" >
<classes>
<class name="com.test.Demo">
<methods preserve-order="true">
<include name="login" />
<include name="addItem" />
<include name="updateItem" />
<include name="deleteItem" />
<include name="logout" />
</methods>
</class>
</classes>
</test>
</suite>
設(shè)置好xml文件后,對(duì)testng.xml右鍵,選擇RunAs->TestNG Suite
執(zhí)行結(jié)果
[TestNG] Running:
C:UserszhangyjworkspaceDemosrc estng.xml
BeforeClass初始化。。。
login開(kāi)始執(zhí)行
addItem開(kāi)始執(zhí)行
updateItem開(kāi)始執(zhí)行
deleteItem開(kāi)始執(zhí)行
logout開(kāi)始執(zhí)行
AfterClass銷毀中。。。
===============================================
Suite
Total tests run: 5, Failures: 0, Skips: 0
===============================================