我有两种方法,如下所示。
我使用testng.xml
执行套件,保留thread-count="2" parallel="methods"
,以便所有@Test
方法将并行执行。
@Test
//this method will be executed in firefox
public void method1(){
WebDriver driver=new FirefoxDriver();
driver.get("https://google.co.in");
line2;
line3;
}
@Test
//this method will be executed other window of firefox
public void method2(){
WebDriver driver=new FirefoxDriver();
driver.get("https:gmail.com"); //has to be executed only after the opening of google in method1
line2; //has to be executed after the line2 of method1
line3; //has to be executed after the line3 of method1
}
两种方法将并行运行,而不相互依赖。但是根据我的要求(在代码注释中提到),是否可以使method2的执行依赖于method1的执行?
答案 0 :(得分:0)
在@Test
中添加以下dependsOnMethods@Test(dependsOnMethods = { "method1" })
public void method2(){
.....
}