0

TestNG.xml > only Executing First TestNG Test

  1. I have copied the exact same working project, setup etc on a new device(PC) but when executing the same testng.xml it seems to execute only the first @Test across all test cases.
  2. Running the test on my existing system works correctly.

  3. For example @Test(priority = 1) only seems to be executing across all my 100+ TestNG Test classes.

Example Test File:

    @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>

If i alter the above testng.xml to execute one test at a time the test executes fine.

Gbru
  • 1,065
  • 3
  • 24
  • 56
  • What IDE are you using? Check your run / debug configurations on your new machine. – Moshisho Nov 14 '16 at 14:19
  • Hi @Moshisho im currently using Eclipse IDE, is there a specific way to check the debug config in Eclipse? – Gbru Nov 14 '16 at 15:04
  • I'm more familiar with IntelliJ, but you can search for it. How are you running the tests, right click on a test, command line, etc..? – Moshisho Nov 14 '16 at 15:31
  • ok @Moshisho currently im running the tests using a TestNg.xml, please refer to the following link: – Gbru Nov 14 '16 at 15:40
  • http://stackoverflow.com/questions/40592208/testng-xml-not-executing-classes-one-by-one – Gbru Nov 14 '16 at 15:41
  • @Phil_P85 - Which post would you like to pursue to get answers ? I have updated the other post with some questions. So maybe you can have this closed off ? – Krishnan Mahadevan Nov 16 '16 at 04:07

1 Answers1

0

@Phil_P85 - This is your testng xml file.

<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>

Can you describe 'PhFramework.pizzas.*' ? If 'pizzas' is your package, can you try doing just '' see if it works.

hifzur
  • 193
  • 3
  • 10