Copyright 2002 by aragost

com.aragost.junit
Class LibraryTest

java.lang.Object
  |
  +--TestSuite
        |
        +--com.aragost.junit.LibraryTest

public class LibraryTest
extends TestSuite

A LibraryTest is a TestSuite that will contain all TestCases in a libray. It will scan a subdirectory or a jar file and collect all test cases.

This class has a main method. When executed it will execute all TestCases under the same root as this class itself. If this class is put in a jar file, and in the manifest file set as the main class, executing the jar file (with java -jar name.jar), will result in all the TestCases of the jar file to me executed.

See Also:
Serialized Form

Constructor Summary
LibraryTest()
          Create an instance of LibraryTest.
LibraryTest(java.lang.Class root)
          Create an instance of LibraryTest for the specified the library containing the specified class.
LibraryTest(java.io.File root)
          Create an instance of LibraryTest for the specified library.
LibraryTest(java.lang.String name)
          Create an instance of LibraryTest with the specified name.
LibraryTest(java.lang.String name, java.io.File root)
          Create an instance of LibraryTest with the specified name, that will contain all test cases in the library specified by root.
 
Method Summary
protected  java.io.File getDefaultRoot()
          The default root, that this class will run all TestCases in.
protected  void init(java.lang.String name, java.io.File root)
           
static void main(java.lang.String[] cmdArgs)
          Execute all TestCases in the same source tree as this class itself.
static TestSuite suite()
          Used by JUnit when executing the Suite.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LibraryTest

public LibraryTest(java.lang.String name,
                   java.io.File root)
Create an instance of LibraryTest with the specified name, that will contain all test cases in the library specified by root.

Parameters:
name - The name of the test
root - The library to test

LibraryTest

public LibraryTest(java.io.File root)
Create an instance of LibraryTest for the specified library.

Parameters:
root - The library

LibraryTest

public LibraryTest(java.lang.Class root)
Create an instance of LibraryTest for the specified the library containing the specified class.

Parameters:
root - The library

LibraryTest

public LibraryTest(java.lang.String name)
Create an instance of LibraryTest with the specified name. This method is used when LibraryTest is used as an argument to one of the junit TestRunner classes.

Parameters:
name - The name of the test

LibraryTest

public LibraryTest()
Create an instance of LibraryTest.

Method Detail

getDefaultRoot

protected java.io.File getDefaultRoot()
The default root, that this class will run all TestCases in. Default is to take the root where the classes itself is located.

This method might be overridden in subclasses to test a another Library. This method is only called when no explicit root is passed when creating an instance.

Returns:
The default root

main

public static void main(java.lang.String[] cmdArgs)
Execute all TestCases in the same source tree as this class itself.

Parameters:
cmdArgs - Command line arguments

init

protected void init(java.lang.String name,
                    java.io.File root)

suite

public static TestSuite suite()
Used by JUnit when executing the Suite.

Returns:
a TestSuite will test cases in the same library as this class.

Copyright 2002 by aragost