Selenium webdriver を使用してサイトをテストするためのこのコードがあります。4 つの@Test
メソッドと、@DataProvider
3 つの値を持つ a があります。したがって、合計で 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 で、すべてのデータ プロバイダーのバリエーションを使用して、これらすべてのテストを繰り返したいと考えています。これらの他の Web ドライバーに対してテストのクラス全体を繰り返すにはどうすればよいですか? @DataProvider
クラス全体(beforemethodの場合)が必要なようです。