TestNG分組測試

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將被執行。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章