The Artima Developer Community
Sponsored Link

SuiteRunner Forum
Order of Execution

4 replies on 1 page. Most recent reply: Aug 11, 2003 9:26 AM by John Smith

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 4 replies on 1 page
Steve Dyson

Posts: 9
Nickname: stevedyson
Registered: Mar, 2003

Order of Execution Posted: May 9, 2003 9:44 AM
Reply to this message Reply
Advertisement
Within a Test Suite is there any easy way to specify the order in which the testMethods are executed, or is this achieved by using sub-suites?


Adam Duffy

Posts: 168
Nickname: adamduffy
Registered: Feb, 2003

Re: Order of Execution Posted: May 12, 2003 6:24 AM
Reply to this message Reply
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.

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.

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

Steve Dyson

Posts: 9
Nickname: stevedyson
Registered: Mar, 2003

Re: Order of Execution Posted: May 16, 2003 10:35 AM
Reply to this message Reply
Thanks!

Bill Venners

Posts: 2284
Nickname: bv
Registered: Jan, 2002

Re: Order of Execution Posted: May 20, 2003 9:17 PM
Reply to this message Reply
> 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

John Smith

Posts: 5
Nickname: jeksmith
Registered: Jan, 2003

Re: Order of Execution Posted: Aug 11, 2003 9:26 AM
Reply to this message Reply
I desire predictable ordering. Alphabetical order works for me. For instance, if I use 2 numbers after "test" but before the test description, then all will be well. An example from the AccountSuite:

public void test01Constructor() { ... }
public void test02Deposit() { ... }
public void test03Withdraw() { ... }

Of course, this can be annoying if I need to add tests or rearrange the test order. Hmmm... Perhaps attributes in JDK 1.5 can guarantee order? Designating test methods using attributes will be cleaner anyway.

Flat View: This topic has 4 replies on 1 page
Topic: Can the Runner to be called? Previous Topic   Next Topic Topic: How to use Invoker

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use