Notifications
Clear all

[Solved] How do I control the order that the tests run in for Selenium?

9 Posts
7 Users
0 Reactions
1,133 Views
0
Topic starter

How can I set the order that the tests are run in?

3 Answers
0

AFAIK there is no easy way to set the order for any JUnit 4 tests using the @Test annotation. The only thing you can do is have one @Test method which calls the actual test methods in the order you want.

http://stackoverflow.com/a/3693706

Sergey Soshnikov 2013-10-08 02:10:00

should not do that since it won't give you visibility to the test stats

Sean Durkin 2013-10-08 10:10:00

What test stats do you need that this method wouldn't provide? If a test fails, you have the full stacktrace.

MythriPericharla 2013-10-08 10:10:00

It will miss the actual number of tests being run. For example, if we have 10 tests in a class, it will then report all of them as 1 test case. Also if one test fails, all other tests will not run that should follow.

0

Junit has no specific order to run test cases. Your best option is to never rely on a previous testcase.
But if it is not possible, you can create one test method and order execution within that method.

But I strongly recommend not trying to order your testcases.

GregMerrill 2013-10-07 17:10:00

I agree with this comment. Build your testcases such that they do not have direct dependencies, i.e. don't require test A to run before test B runs. If they both have some preconditions that are required, then factor out a common method called by both independently.

0

I have added enhancement into plt-8.3.1 to let developer order UI test cases.

To order test case you need to add OrderedUITest to test method annotation:

@Test
@OrderedUITest(order = 1)
public void testMultipleMvmtReportForBulkPrint() throws Exception {
....
}

All test cases without OrderedUITest annotation will run after ordered.