I've been playing around with ANT to try and execute several tests in a specific order but have not been able to find out how to do it. Basicly, I am trying to automate the running of a regression/functional test suite for a web application that runs using Selenium. The test suite that i have has the following structure
At the moment each test is run manually so someone has to load the application on teh browser and type everything into the relevant pages. Now i am using Selenium wich will automate this. I would like to use ANT so that i can have a target for each of the above stages. This means i can either run all the tests or i can run a specific Stage. Example Targets will be something like
I have seen several ANT build examples on how to run junit test, for example,
but i still have not seen an example that would run the tests in a specific order. I have written the test cases using Junit 4 and each stage listed above is a test suite.
Each testsuite contains the relevant testcases. Here is an example
Then on the actual test case i would like to use the browser object
If i was to run the above testsuite in ant i will probably do something liek this
1. Given that i am specifying mytests.Stage1TestSuite as the test to run, how do i guarantee that the tests will run in the order they are specified in the test suite?
2. I have thought about not using testsuites and refere to the individual test cases in the ant junit target but this will be overkill as there will be thousands of test cases.
Posting my reply from your other thread here since it is essentially the same question.
O. Ziggy wrote:if i have 5 test suites in the **/tests/ folder. How will it know which test suite to run first if i run the tests.integration target?
It won't. What's the difference which one gets run first. They are supposed to be independent. If order really does matter, you should rreate a new TestSuite where you run the code in the desired order and have Ant run just that one.
Ok here is the kind of scenario where i would want the test cases to be run a specific order.
Lets say i have a website where you cant do anything without logging on. In this case i have a test case that tests the logging on functionality and then i would have another test case that would test something else. The order they will be executed will matter because i cant test anything before logging on which means the order should be
in the above test cases, i cant read any product before it is created and that i have logged and i cant create a product before i have logged on. I have seen a lot of comments about using the setUp() and tearDown() methods but surely that would mean a lot of duplication.
If for example i have to make TestReadProduct test case independent, i would have to put the TestLogin and TestCreateproduct functionality in the setUp() method for the TestCreateProduct test case. Surely this is a maintenance nightmare. Imagine having to maintain 5000 of testcases. I would have to make a lot of changes in a lot of places if the TestLogin functionality changes.
I am thinking of using the "depends" option in ANT.