Executing Selenium Tests in a certain order using ANT

I have about 40 Class with Selenium WebDriver JUnit tests. Currently, I am using ANT to build and execute tests.

Right now, the test are executing in an alphabetical order. I need to run the tests in a certain order as some of these are dependent on another. I am looking if anyone knows where in build.xml file, I can tell it to run in certain sequence. If I leave it to run in an Alphabetical order, as the number of test grows, it will be tough to name it accordingly and its not a best practice either.

For example, here is the my test order right now.
1. TestNoGroupExists
2. TestCreateGroup
3. TestDrillDown
4. TestDeleteGroup

#3 and #4 are dependent on #2. Now I need to add a test which is also dependent on #2. But it has to run before #3. So, I was looking at option if I can tell ANT run in the following sequence.

1. TestNoGroupExists
2. TestCreateGroup
3. TestDrillDown
4. TestSetGroup

Is there a way to do this ? Any information would be helpful. If you need the build.xml file, I can post it here as well.


Add Comment
  • 1 Answer(s)



    Wondering if you have checked stackoverfow –  this is discussed topic, see. e.g. order attribute  suggested in


    http://stackoverflow.com/questions/3693626/how-to-run-test-methods-in-specific-order-in-junit4 – I have not exercised this particular one, positive about its ability…



    Train Answered on May 13, 2016.
    Add Comment
  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.