JUnit-addons
version 1.4

junitx.util
Class DirectorySuiteBuilder

java.lang.Object
  |
  +--junitx.util.AbstractSuiteBuilder
        |
        +--junitx.util.DirectorySuiteBuilder

public class DirectorySuiteBuilder
extends junitx.util.AbstractSuiteBuilder

Extracts the testcases from a directory. Use the TestFilter to specify the pattern of the classes to load.

Example

Returns a suite containing all classes matching the pattern "*Test. class" from the directory /home/project/myproject/tests:

     DirectorySuiteBuilder builder = new DirectorySuiteBuilder();
     Test suite = builer.suite("/home/project/myproject/tests");
 
Returns a suite containing all tests from files starting with "Sample" and ending with "Test". /home/project/myproject/tests

     DirectorySuiteBuilder builder = new DirectorySuiteBuilder();
     builder.setFilter(new TestFilter() {

          public boolean include(String classpath) {
              return super.include(classpath) && 
                  SimpleTestFilter.getClassName(classpath).startsWith("Sample");
          }
 
     });

     Test suite = builder.suite("/home/project/myproject/tests");
 

Version:
$Revision: 1.6 $ $Date: 2003/04/28 05:18:28 $
Author:
Vladimir R. Bossicard, Naidu Purushotham

Constructor Summary
DirectorySuiteBuilder()
          Constructs an empty DirectorySuiteBuilder object.
DirectorySuiteBuilder(TestFilter filter)
          Constructs an DirectorySuiteBuilder object with the given filter.
 
Method Summary
protected  java.util.List browse(java.io.File directory)
          Returns the list of test classes contained in the directory.
protected  boolean isTestClass(java.lang.String path)
          Returns true if the given path refers a test class.
protected  void merge(java.util.List classenames, junit.framework.TestSuite suite)
          Populates the suite with test cases extracted from the classnames list.
 void setFilter(TestFilter filter)
          Sets the filter defining the test classes to be included.
 junit.framework.Test suite(java.io.File directory)
          Constructs a TestSuite by extracting all test classes from the given directory.
 junit.framework.Test suite(java.lang.String directoryName)
          Constructs a TestSuite by extracting all test classes from the directory of the given directoryName.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DirectorySuiteBuilder

public DirectorySuiteBuilder()
Constructs an empty DirectorySuiteBuilder object.


DirectorySuiteBuilder

public DirectorySuiteBuilder(TestFilter filter)
Constructs an DirectorySuiteBuilder object with the given filter.

Method Detail

suite

public junit.framework.Test suite(java.io.File directory)
                           throws java.lang.Exception
Constructs a TestSuite by extracting all test classes from the given directory.

java.lang.Exception

suite

public junit.framework.Test suite(java.lang.String directoryName)
                           throws java.lang.Exception
Constructs a TestSuite by extracting all test classes from the directory of the given directoryName.

java.lang.Exception

browse

protected java.util.List browse(java.io.File directory)
                         throws java.lang.Exception
Returns the list of test classes contained in the directory. Method defined for testing only: no support guarantee.

java.lang.Exception
See Also:
AbstractSuiteBuilder.isTestClass(java.lang.String)

setFilter

public void setFilter(TestFilter filter)
Sets the filter defining the test classes to be included.


isTestClass

protected boolean isTestClass(java.lang.String path)
Returns true if the given path refers a test class.


merge

protected void merge(java.util.List classenames,
                     junit.framework.TestSuite suite)
              throws java.lang.ClassNotFoundException,
                     java.lang.IllegalAccessException,
                     java.lang.reflect.InvocationTargetException
Populates the suite with test cases extracted from the classnames list.

java.lang.ClassNotFoundException
java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException

JUnit-addons
version 1.4

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