TestNG' dependsOnMethods'停止'线程数'从工作?
我使用的x3 TestNG类依赖于列出的方法:
第一课:
pip install tensorflow=1.2.0rc2
第二课:
public class AddABookingTest extends BrowserFactory {
@Test(priority = 1)
public void load_BookingSystemHomepage() throws Exception {
supplierHome_BookingSystem_Page.loadBookingSystemHomePage();
}
@Test(priority = 2, dependsOnMethods={"load_BookingSystemHomepage"})
public void enter_UserLoginDetails_Login_Page() throws Exception {
basePage.sendKeysToWebElement(login_BookingSystem_Page.textField_UserName, "x");
basePage.sendKeysToWebElement(login_BookingSystem_Page.textField_Password, "xx");
}
@Test(priority = 3, dependsOnMethods={"load_BookingSystemHomepage", "enter_UserLoginDetails_Login_Page"})
public void clickOn_Login_Button() throws Exception {
basePage.waitAndClickElement(login_BookingSystem_Page.button_Login);
}
第3课:
public class AddABookingTest2 extends BrowserFactory {
@Test(priority = 1)
public void load_BookingSystemHomepage() throws Exception {
supplierHome_BookingSystem_Page.loadBookingSystemHomePage();
}
@Test(priority = 2, dependsOnMethods={"load_BookingSystemHomepage"})
public void enter_UserLoginDetails_Login_Page() throws Exception {
basePage.sendKeysToWebElement(login_BookingSystem_Page.textField_UserName, "x");
basePage.sendKeysToWebElement(login_BookingSystem_Page.textField_Password, "xx");
}
@Test(priority = 3, dependsOnMethods={"load_BookingSystemHomepage", "enter_UserLoginDetails_Login_Page"})
public void clickOn_Login_Button() throws Exception {
basePage.waitAndClickElement(login_BookingSystem_Page.button_Login);
}
当执行我的TestNG XML文件时,所有x3类似乎同时打开,即使我已将线程数设置为2,如果我删除所有依赖项,一切正常吗?
public class AddABookingTest3 extends BrowserFactory {
@Test(priority = 1)
public void load_BookingSystemHomepage() throws Exception {
supplierHome_BookingSystem_Page.loadBookingSystemHomePage();
}
@Test(priority = 2, dependsOnMethods={"load_BookingSystemHomepage"})
public void enter_UserLoginDetails_Login_Page() throws Exception {
basePage.sendKeysToWebElement(login_BookingSystem_Page.textField_UserName, "x");
basePage.sendKeysToWebElement(login_BookingSystem_Page.textField_Password, "xx");
}
@Test(priority = 3, dependsOnMethods={"load_BookingSystemHomepage", "enter_UserLoginDetails_Login_Page"})
public void clickOn_Login_Button() throws Exception {
basePage.waitAndClickElement(login_BookingSystem_Page.button_Login);
}
新代码:
XML文件:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="Automation_Scripts_by_GBruno" verbose="2" parallel="classes" thread-count="2">
<test name="Automation Tests">
<packages>
<package name="Framework.complete.*"></package>
</packages>
</test>
</suite>
<?xml version="1.0" encoding="UTF-8"?>
测试类1:
<test name="Framework Automation Tests">
<packages>
<package name="Framework.url2.*"></package>
</packages>
</test>
测试类2:
import org.testng.annotations.Test;
import Framework.utilities.BrowserFactory;
public class UrlCheckerTest extends BrowserFactory {
@Test(priority=1)
public void checkURL_Test1() throws Exception {
getDriver().get("https://www.google.com");
Thread.sleep(5000);
}
@Test(priority=2)
public void checkURL_Test2() throws Exception {
getDriver().get("https://www.amazon.com");
}
}
Test3的:
import org.testng.annotations.Test;
import Framework.utilities.BrowserFactory;
public class UrlCheckerTest2 extends BrowserFactory {
@Test(priority=1)
public void checkURL_Test1() throws Exception {
getDriver().get("https://www.google.com");
Thread.sleep(5000);
}
@Test(priority=2)
public void checkURL_Test2() throws Exception {
getDriver().get("https://www.amazon.com");
}
}
TEST4:
import org.testng.annotations.Test;
import Framework.utilities.BrowserFactory;
public class UrlCheckerTest extends BrowserFactory {
@Test(priority=1)
public void checkURL_Test1() throws Exception {
getDriver().get("https://www.google.com");
Thread.sleep(5000);
}
@Test(priority=2)
public void checkURL_Test2() throws Exception {
getDriver().get("https://www.amazon.com");
}
}
浏览器工厂: 受保护的WebDriver webdriver;
import org.testng.annotations.Test;
import Framework.utilities.BrowserFactory;
public class UrlCheckerTest extends BrowserFactory {
@Test(priority=1)
public void checkURL_Test1() throws Exception {
getDriver().get("https://www.google.com");
Thread.sleep(5000);
}
@Test(priority=2)
public void checkURL_Test2() throws Exception {
getDriver().get("https://www.amazon.com");
}
}