您的位置:軟件測(cè)試 > 開源軟件測(cè)試 > 開源單元測(cè)試工具 > TestNG
TestNG基本注釋一:簡(jiǎn)單實(shí)例
作者:網(wǎng)絡(luò)轉(zhuǎn)載 發(fā)布時(shí)間:[ 2014/2/7 10:00:42 ] 推薦標(biāo)簽:TestNG 單元測(cè)試框架

  一個(gè)簡(jiǎn)單類的實(shí)例,指引你如何開始使用testng單元測(cè)試框架。
  使用的工具:
  TestNG 6.8.7
  Maven 3
  Eclipse IDE
  1.testng依賴
  在pom.xml中添加testng庫:
  pom.xml
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8.7</version>
<scope>test</scope>
</dependency>
  2.testng實(shí)例
package test.java.com.testng.test;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.DataProvider;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.AfterSuite;
public class LoginTest {
@Test(dataProvider = "dp")
public void f(Integer n, String s) {
}
@BeforeMethod
public void beforeMethod() {
}
@AfterMethod
public void afterMethod() {
}
@DataProvider
public Object[][] dp() {
return new Object[][] {
new Object[] { 1, "a" },
new Object[] { 2, "b" },
};
}
@BeforeClass
public void beforeClass() {
}
@AfterClass
public void afterClass() {
}
@BeforeTest
public void beforeTest() {
}
@AfterTest
public void afterTest() {
}
@BeforeSuite
public void beforeSuite() {
}
@AfterSuite
public void afterSuite() {
}
}

軟件測(cè)試工具 | 聯(lián)系我們 | 投訴建議 | 誠(chéng)聘英才 | 申請(qǐng)使用列表 | 網(wǎng)站地圖
滬ICP備07036474 2003-2017 版權(quán)所有 上海澤眾軟件科技有限公司 Shanghai ZeZhong Software Co.,Ltd