我有这段代码用于使用 selenium webdriver 测试网站。有四种@Test
方法,一个@DataProvider
具有三个值。因此,总共运行了 12 个测试。
public class SomeTest {
WebDriver driver;
@DataProvider(name = "URLs")
public Object[][] createData1() {
return new Object[][] {
{"url 1"},
{"url 2"},
{"url 3"}};
}
@BeforeMethod
//right now I'm just setting up weddriver for chrome, but
//I'll need to run this test for firefox, chrome, and IE
public void setUpWebDriver(){
driver = WebDrivers.getChromeDriver();
}
@AfterMethod
public void closeWebDriver(){
driver.quit();
}
//test methods below
@Test(dataProvider = "URLs")
public void test1(String url){
//test 1 with url
}
@Test(dataProvider = "URLs")
public void test2(String url){
//test 2 with url
}
@Test(dataProvider = "URLs")
public void test3(String url){
//test 3 with url
}
@Test(dataProvider = "URLs")
public void test4(String url){
//test 4 with url
}
}
目前,这些测试正在 Chrome 下运行。但我还想在 Firefox 和 Internet Explorer 上重复所有这些测试,以及所有数据提供程序的变体。我怎样才能让整个类的测试为这些其他 webdrivers 重复?这几乎就像我需要@DataProvider
整个班级的(对于之前的方法)。