[英]Why is @DataProvider annotation runs before @BeforeClass in TestNG?
这就是今天实施的方式,这对你来说是个问题吗?
Please find the sequence of execution below: 请在下面找到执行顺序:
@BeforeSuite
@BeforeTest
@BeforeClass
@DataProvider
@BeforeMethod
@AfterMethod
@AfterClass
@AfterTest
@AfterSuite
@BeforeClass
@课前
BeforeClass annotation
Method runs only once before the first test method. BeforeClass annotation
方法仅在第一个测试方法之前运行一次。 The Current Class method will be one from which it is invoked. Current Class方法将是调用它的方法。
@DataProvider
@dataProvider
DataProvider annotation
method returns an Object[ ][ ] type value, where each Object[ ] can be assigned as the parameter of the test method that wants to receive the data from this DataProvider annotation method. DataProvider annotation
方法返回Object [] []类型值,其中每个Object []可以指定为希望从此DataProvider注释方法接收数据的测试方法的参数。
public class TestNgDataProviderExample {
@BeforeClass
public void beforeClass() {
System.out.println("in beforeClass");
}
@Test(dataProvider = "getData")
public void instanceDbProvider(int p1, String p2) {
System.out.println("DataProvider Data(" + p1 + ", " + p2 + ")");
}
@DataProvider
public Object[][] getData() {
return new Object[][] {{5, "five"}, {6, "six"}};
}
}
Output: 输出:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.