Hi,
I am new to TESTNG and started using it recently, and while working with @groups tag I have noticed that, the methods inside the groups are executed in alphabetical order.But normal @TEST methods are not bound to this restriction.Due to this my test suite started failing as please see the details of my code and xml below /** * @throws Exception * this method will set the execution environment(the application type i.e.web application or mobile application or * client application or API testing) * if web application is to be automated then pass the required browser else pass null in browser */ @BeforeGroups (groups = {"login"} ) public void setApplicationEnvironment()throws Exception { //set the test execution environment tc1.setApplicationEnvironment(AndroidApplication); } @Test (groups = {"login"} ) public void openApp() throws Exception{ tc1.userWait(4); tc1.clickElement(ImageFilePath+"snapsecurehtc.png"); tc1.userWait(15); //tc1.isElementPresent(ImageFilePath+"validateopenapp.png"); //tc1.userWait(2); } @Test (groups = {"login"} ) public void inValidLogin() throws Exception{ tc1.clickElement(ImageFilePath+"signininbutton.png"); tc1.userWait(4); tc1.clickElement(ImageFilePath+"click@.png"); tc1.userWait(2); tc1.SendKey(UserKey.DOWN); tc1.SendKey(UserKey.UP); tc1.clearContent("[hidden email]", ImageFilePath+"backspacehtc.png"); tc1.userWait(4); tc1.sendText("[hidden email]"); tc1.SendKey(UserKey.DOWN); tc1.sendText("dsfsdft"); tc1.SendKey(UserKey.DOWN); tc1.SendKey(UserKey.ENTER); tc1.userWait(5); tc1.clickElement(ImageFilePath+"okbutton.png"); tc1.userWait(2); tc1.isElementPresent(ImageFilePath+"validateopenapp.png"); tc1.userWait(2); } [6:56:07 PM] pooja verma: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd"> <suite name="Suite" parallel="none"> <test name="Test" preserve-order="false"> <groups> <run> <include name="login"> </include> </run> </groups> <classes> <class name="TestScript/> </classes> </test> <!-- Test --> </suite> <!-- Suite --> All the time in the group the execution starts from inValidLogin, but I want the test to be executed as defined in the order like setApplicationEnvironment, OpenApp, and inValidLogin and so on Please let me know what I Am missing here?Is the desired behaviour for @groups annotation?How I can make this to work in the expected order? I have tried use preserving-order, but it didn't work, please give some solution for the same Regards, Kiran
-- You received this message because you are subscribed to the Google Groups "testng-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at http://groups.google.com/group/testng-users. For more options, visit https://groups.google.com/groups/opt_out. |
http://testng.org/doc/documentation-main.html#dependent-methods
TestNG does not explicitly garauntee the runtime order unless you specify it. When dealing with methods that need to be executed in a specific order you need to specify their order. There are a couple of ways to do this, but the most reliable would be to use dependent-methods. In your case: @Test (groups = {"login"}) public void openApp() throws Exception {...} @Test (groups = {"login"} , dependsOnMethods={"openApp"} ) public void inValidLogin() throws Exception {...} You received this message because you are subscribed to the Google Groups "testng-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at http://groups.google.com/group/testng-users. For more options, visit https://groups.google.com/groups/opt_out. |
Free forum by Nabble | Edit this page |