JUnit-addons
version 1.4

junitx.framework
Class OrderedTestSuite

java.lang.Object
  |
  +--junitx.framework.TestSuite
        |
        +--junitx.framework.OrderedTestSuite
All Implemented Interfaces:
junit.framework.Test

public class OrderedTestSuite
extends junitx.framework.TestSuite

Constructs an alphabetically ordered suite of tests.

Warning: if you are tempted to use this class, think twice before doing it. Ideally the tests should be independant from one another so first try to refactor them and use the TestSetup class to initialize them. But if you still want to use this class... it's up to you.

Version:
$Revision: 1.5 $ $Date: 2003/03/30 19:02:57 $
Author:
Vladimir R. Bossicard

Field Summary
protected  java.util.List fTests
           
 
Constructor Summary
OrderedTestSuite()
          Creates an OrderedTestSuite with no name.
OrderedTestSuite(java.lang.Class theClass)
          Constructs a OrderedTestSuite from the given class.
OrderedTestSuite(java.lang.String name)
          Creates an OrderedTestSuite with the given name.
 
Method Summary
 void addTest(junit.framework.Test test)
          Adds a test to the suite.
 void addTestSuite(java.lang.Class testClass)
          Adds the tests from the given class to the suite
 int countTestCases()
          Counts the number of test cases that will be run by this test.
 java.lang.String getName()
          Returns the name of the suite.
 void run(junit.framework.TestResult result)
          Runs the tests and collects their result in a TestResult.
 void runTest(junit.framework.Test test, junit.framework.TestResult result)
           
 void setName(java.lang.String name)
          Sets the name of the suite.
protected  void sortTests(int left, int right)
           
 junit.framework.Test testAt(int index)
          Returns the test at the given index
 int testCount()
          Returns the number of tests in this suite
 java.util.Enumeration tests()
          Returns the tests as an enumeration
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

fTests

protected java.util.List fTests
Constructor Detail

OrderedTestSuite

public OrderedTestSuite()
Creates an OrderedTestSuite with no name.


OrderedTestSuite

public OrderedTestSuite(java.lang.Class theClass)
Constructs a OrderedTestSuite from the given class. Adds all the methods starting with "test" as test cases to the suite.

The method calls addTest for each insertion of test methods found so the sorting is done for each method, and not at the end.


OrderedTestSuite

public OrderedTestSuite(java.lang.String name)
Creates an OrderedTestSuite with the given name.

Method Detail

addTest

public void addTest(junit.framework.Test test)
Adds a test to the suite. The elements are sorted after beeing inserted into the vector.

Overrides:
addTest in class junitx.framework.TestSuite

sortTests

protected void sortTests(int left,
                         int right)

addTestSuite

public void addTestSuite(java.lang.Class testClass)
Adds the tests from the given class to the suite


countTestCases

public int countTestCases()
Counts the number of test cases that will be run by this test.

Specified by:
countTestCases in interface junit.framework.Test

run

public void run(junit.framework.TestResult result)
Runs the tests and collects their result in a TestResult.

Specified by:
run in interface junit.framework.Test

runTest

public void runTest(junit.framework.Test test,
                    junit.framework.TestResult result)

testAt

public junit.framework.Test testAt(int index)
Returns the test at the given index


testCount

public int testCount()
Returns the number of tests in this suite


tests

public java.util.Enumeration tests()
Returns the tests as an enumeration


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

setName

public void setName(java.lang.String name)
Sets the name of the suite.

Parameters:
name - The name to set

getName

public java.lang.String getName()
Returns the name of the suite. Not all test suites have a name and this method can return null.


JUnit-addons
version 1.4

Copyright © 2002-2003 Vladimir R. Bossicard. All Rights Reserved.