2016-11-14 37 views
0

的testng.xml>僅執行一TestNG的測試的testng.xml>僅執行一TestNG的測試

  1. 我抄完全相同的工作項目,新設備(PC)上安裝等,但執行相同的時testng.xml它似乎只執行所有測試用例中的第一個@Test。
  2. 在我現有的系統上運行測試可正常工作。

  3. 例如@Test(priority = 1)似乎只在我所有的100+ TestNG Test類中執行。

實施例測試文件:

@Test(priority = 1) 
public void LoadPage() throws Exception { 
    basePage.loadPage(); 

    //Logs whether the Url and page Title is correct 
    DOMConfigurator.configure("log4j.xml"); 
    Log.info("@PASS ---> Expected Site URL: " + basePage.page_url + " | Found the following Site URL: " + basePage.getPageUrl()); 
    Log.info("@PASS ---> Expected Page Title: " + basePage.page_title + " | Found the following title: " + basePage.getPageTitle()); 
} 

@Test(priority = 2) 
public void hutLocaliseAndSelectOrderType() throws Exception { 
    phHomepage.enterHutPostcode(); 
    hutLocalisePage.selectOrderType(); 
} 

@Test(priority = 3) 
public void SignIntoAccount() throws Exception { 
    basePage.pageJSLoadAndClick(pageHeader.button_SignIn); 

    //Sign into Account 
    signInPage.signIntoAccount(); 

    //Validate whether Sign Out button is visible, once successfully signed into account 
    pageHeader.signOutButtonIsDisplayed(); 
} 


**Listed in BasePage.java class** 
public void loadPage() throws Exception{ 
    driver.get(page_url); 
    Assert.assertEquals(driver.getCurrentUrl(), getPageUrl()); 
    Assert.assertEquals(driver.getTitle(), getPageTitle()); 
} 

<suite name="PH_Automation_Scripts_by_GBruno" verbose="2"> 
<test name="PH Automation Tests: Pizza Combinations" parallel="false"> 
    <packages> 
     <package name="PhFramework.pizzas.*" /> 
    </packages> 
</test> 

如果我改變上述的testng.xml在一個時間該測試執行細以執行一個測試。

+0

你在用什麼IDE?檢查新機器上的運行/調試配置。 – Moshisho

+0

嗨@Moshisho im當前正在使用Eclipse IDE,有沒有特定的方法來檢查Eclipse中的調試配置? – Gbru

+0

我更熟悉IntelliJ,但可以搜索它。你如何運行測試,右鍵單擊測試,命令行等。? – Moshisho

回答

0

@ Phil_P85 - 這是你的testng xml文件。

<suite name="PH_Automation_Scripts_by_GBruno" verbose="2"> 
<test name="PH Automation Tests: Pizza Combinations" parallel="false"> 
    <packages> 
     <package name="PhFramework.pizzas.*" /> 
    </packages> 
</test> 

你能描述'PhFramework.pizzas。*'嗎?如果'披薩'是你的包裝,你可以嘗試只是''看看它是否有效。