我有一個多個Test類,我想執行4個測試,但是,我想執行的4個測試是不同類文件中的不同類。所以我想在我的多個Test類中每次調用每個類1。所以代碼正在各個類中執行,多個Test類實際上只是根據優先級來處理每個測試的執行。我只是不確定如何調用另一個類來執行。TestNG多測試類 - 運行其他類
我多類:
@Test(priority = 0) //Set Priority of Test - Priority of test always starts from Zero
public void one() {
System.out.println("This is Test Case 1");
}
//Test 2
@Test(priority = 1) // Test priority 1
public void Two(){
System.out.println("This is Test Case 2");
}
我需要在@Test塊來執行我的外部類。新自動化可能我的問題是我對java的理解?
如何我通過我的參數:在執行這些主類文件單獨的類文件&
public class TestNGDataProvider {
private WebDriver driver;
private static Logger logger1 = LogManager.getLogger("Logger1");
@Test(dataProvider = "Authentication")
public void testMethod1(String sUsername, String sPassword, String sMemorableWord) {
DOMConfigurator.configure("log4j.xml");
driver = new FirefoxDriver();
logger1.info("New Instance of firefox created");
//Add wait to allow web elements to load
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
logger1.info("Timeout Applied for 10 seconds to Allow Load of Elements");
//Launch FireFoxDriver - Open WebPage
driver.get("http://localhost/2010A15/");
logger1.info("Website Launched");
Reporter.log("Website Lauched Successfully | "); //Main Event Logger/Report
//Find Login Element
driver.findElement(By.id("WEB_LoginButton")).click();
logger1.info("Login Button Clicked");
//Find User name Element
driver.findElement(By.id("dijit_form_ValidationTextBox_1")).sendKeys(sUsername);
logger1.info("Username Entered");
//Find Password Element
driver.findElement(By.id("dijit_form_ValidationTextBox_2")).sendKeys(sPassword);
@DataProvider(name = "Authentication")
public static Object[][] credentials() {
return new Object[][] { { "[email protected]", "password1", "smith" }, { "[email protected]", "password1", "smith" }, { "[email protected]", "password1", "smith" }};
}}
所以,你有4個差異類與4個測試方法,你想所有的測試類應該運行所有4個測試用例基於優先權嗎? – Paras