I have created a JUnittest class in which I would like the various "test" methods to be run in a specific order. I have found that the test methods execute in different sequences depending upon the JVM that the JUnit test class is run in. Looking at the API, I thought that overriding runTest() was the answer but this apparently executes once for each "test" method in the JUnit test class (and there are 8 in my test class). So, it executes the test methods in the proper order but it does so 8 times in my JUnit test class! My immediate solution is to use a static count variable, check and increment it during runTest() execution. The other possible solution would be to rename all the "test" methods on the JUnit test class. However, it seems there should be an easier way. I would appreciate any suggestions.
posted 12 years ago
Why do you want the tests to run in a specific order? I hope you don't have any state dependencies between test methods...