1

I have the following xml file:

<suite name= "Ecommerce suite" group-by-instances="true" parallel="methods"> 
<test name = "Sanity tests" verbose = "2" >
    <classes>
        <class name = "tutorialTestNG.Search">
        </class>
        <class name = "tutorialTestNG.AccountFunds">
        </class>
    </classes>
</test>

and these two classes:

    public class Search {
            @BeforeTest
            public void login(){
                System.out.println("Successfully logged in!");
            }
            @AfterTest
            public void logout(){
                System.out.println("Successfully logged out!");
            }
            @Test (priority = 1)
            public void search(){
                System.out.println("Successfully searched!");
            }
            @Test (priority = 2)
            public void advancedSearch(){
                System.out.println("Successfully advance searched!");
            }
            @Test (priority = 3)
            public void buyProducts(){
                System.out.println("Successfully bought products!");
            }

    }       



     public class AccountFunds {

        @Test (priority = 1)
        public void accountSummary(){
            System.out.println("Successfully brought summary of the account!");
        }
        @Test (priority = 2)
        public void fundTransfer(){
            System.out.println("Successfully transferred funds!");
        }
        @Test (priority = 3)
        public void billPayment(){
            System.out.println("Successfully paid bills!");
        }
}

The problem is that when i run the test suite, the methods from both classes with priority = 1 are ran, instead of all methods from one class first and then the other methods from second class. So the output is something like this:

Successfully logged in!
Successfully searched!
Successfully brought summary of the account!
Successfully advance searched!
Successfully transferred funds!
Successfully bought products!
Successfully paid bills!
Successfully logged out!

Any idea why this occurs even though i set group-by-instances variable true?

Tudor
  • 199
  • 3
  • 14
  • You may have found an issue and I opened a ticket: https://github.com/cbeust/testng/issues/1252 Could you try to replace `priority` by `dependsOnMethods`? – juherr Nov 23 '16 at 19:40
  • Hi Julien, Using dependsOnMethods is working, the tests are prioritized as they should. However, I'm still intresested in why the `priority` argument is not working, as there is a tutorial on the internet that i was following which contains classes and methods almost identical with the ones i wrote (only the sysouts are different, which does not matter). His output is different though, as the methods are correctly prioritized in his example, opposed to mine where this issue occurs. Please keep me posted about this. Cheers, \T – Tudor Nov 24 '16 at 09:57
  • Could you share the like to the tutorial you followed? – juherr Nov 24 '16 at 10:21
  • Check my answer on http://stackoverflow.com/a/42438870/4234729 – juherr Feb 24 '17 at 13:59

0 Answers0