TestNG分组测试

来源:互联网 发布:济源知乎 编辑:程序博客网 时间:2024/05/22 05:22

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将被执行。

0 0
原创粉丝点击