大家好,欢迎来到IT知识分享网。
package testng;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.AfterMethod;
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 FirstTest {
@Test
public void f() {
System.out.println(“foo”);
}
@DataProvider(name = “Data”)
public static Object[][] Data() {
return new Object[][]{
{“11”},{“22”}};
}
@Test(dataProvider = “Data”, priority = 1)
public void f1(String txt) {
System.out.println(“f1” + txt);
}
@BeforeMethod
public void beforeMethod() {
System.out.println(“@beforeMethod”);
}
@AfterMethod
public void afterMethod() {
System.out.println(“@afterMethod”);
}
@BeforeClass
public void beforeClass() {
System.out.println(“@beforeClass”);
}
@AfterClass
public void afterClass() {
System.out.println(“@afterClass”);
}
@BeforeTest
public void beforeTest() {
System.out.println(“@beforeTest”);
}
@AfterTest
public void afterTest() {
System.out.println(“@afterTest”);
}
@BeforeSuite
public void beforeSuite() {
System.out.println(“@beforeSuite”);
}
@AfterSuite
public void afterSuite() {
System.out.println(“@afterSuite”);
}
}
<?xml version=”1.0″ encoding=”UTF-8″?>
<!DOCTYPE suite SYSTEM “http://testng.org/testng-1.0.dtd”>
<suite name=”Suite” parallel=”none”>
<test name=”First TestNG demo”>
<classes>
<class name=”testng.FirstTest”/>
</classes>
</test>
</suite>
免责声明:本站所有文章内容,图片,视频等均是来源于用户投稿和互联网及文摘转载整编而成,不代表本站观点,不承担相关法律责任。其著作权各归其原作者或其出版社所有。如发现本站有涉嫌抄袭侵权/违法违规的内容,侵犯到您的权益,请在线联系站长,一经查实,本站将立刻删除。 本文来自网络,若有侵权,请联系删除,如若转载,请注明出处:https://yundeesoft.com/12602.html