Pre-requisite: TestNG已安装
1. 在测试方法中加入分组信息:
public class FirstTest {
@Before
public void testCase0() throws Exception {
......
}
@Test(groups = { "func" })
public void testCase1() throws InterruptedException {
......
}
@Test(groups={ "perf" })
public void testCase2() {
......
}
@After
public void testCase3() {
}
}
2. 修改testng.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite" parallel="none">
<test name="Test">
<groups>
<run>
<include name="perf" />
</run>
</groups>
<classes>
<class name="FirstTest"/>
</classes>
</test> <!-- Test -->
</suite> <!-- Suite -->
3. 在工程上右键点击testng.xml->run as testng.
testCase0, testCase2, testCase3将被执行。