|
|
Re: Order of Execution
|
Posted: May 20, 2003 9:17 PM
|
|
> The order in which the test methods are executed is: > > 1. Test methods in a Suite will be executed before > test methods in a Sub-Suite. > This is true if you are using the implementations of execute, executeSubSuites, and executeTestMethods, that come with Suite. You can override these methods in subclasses if you want different behavior.
> 2. In a Suite, all methods with no parameters are executed > in order and then all methods that take Reporter in the > parameter are executed. > That's true, but there's no guarantee of any order in the contract of the executeTestMethods method. I say subclasses can define an order if they want. However, I have been thinking I should go ahead and define an order for Suite's executeTestMethods contract in the next release, because I know people often want to execute tests in a particular order. I would guess alphabetical order would be the easiest. Unfortunately, order of appearance in the source file I don't think works, because I don't believe the compiler must put things in the same order in the class file, and I don't know that I can figure out the class file's method order via reflection anyway.
> For example > > > public class MySuite extends Suite
> {
> public void testFirst()
> {
> // Order : 1
> }
>
> public void testSecond()
> {
> // Order : 2
> }
>
> public void testFourth( Reporter r )
> {
> // Order : 4
> }
>
> public void testThird()
> {
> // Order : 3
> }
> }
>
> > Hope this helps, > Adam
|
|