net.sourceforge.groboutils.junit.v1.parser
Class TestClassParser

java.lang.Object
  extended bynet.sourceforge.groboutils.junit.v1.parser.TestClassParser

public class TestClassParser
extends java.lang.Object

Parses Test classes to discover the usable test methods.

Ripped the test method discovery code out of junit.framework.TestSuite to allow it to have usable logic.

This is not covered under the GroboUtils license, but rather under the JUnit license (IBM Public License). This heading may not be totally in line with the license, so I'll change it when I find out what needs to be changed.

Since:
March 28, 2002
Version:
$Date: 2002/11/05 00:49:31 $
Author:
Matt Albrecht groboclown@users.sourceforge.net

Constructor Summary
TestClassParser(java.lang.Class theClass)
          The primary constructor, which will cause this instance to know how to parse only the passed-in class.
 
Method Summary
protected  void addTestMethod(java.lang.reflect.Method m, java.util.Vector names)
          Adds the method m to the inner list of known test methods, but only if it is a public test method.
 void clearWarnings()
          Remove all current warnings.
protected  void discoverTestMethods(java.lang.Class theClass)
          Discover and record the test methods of the public test class theClass.
 java.lang.String getName()
          Get the name of the test suite.
 java.lang.Class getTestClass()
          Get the class under test.
 java.lang.reflect.Method[] getTestMethods()
          Retrieve all public test methods discovered through inspection.
 java.lang.String[] getWarnings()
          Retrieve all warnings generated during the introspection of the class, or test creation.
protected  boolean isPublicTestMethod(java.lang.reflect.Method m)
          Asserts that the method is public, and that it is also a test method.
protected  boolean isTestMethod(java.lang.reflect.Method m)
          Test if method m is a test method, which means it accepts no parameters, returns void, and the name of the method begins with test.
protected  boolean testClass(java.lang.Class theClass)
          Discover if the given class is a valid testing class.
protected  void warning(java.lang.String message)
          Adds a warning message to the inner list of warnings.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TestClassParser

public TestClassParser(java.lang.Class theClass)
The primary constructor, which will cause this instance to know how to parse only the passed-in class.

Parameters:
theClass - the class to parse for testing.
Throws:
java.lang.IllegalArgumentException - if theClass is null.
Method Detail

getWarnings

public java.lang.String[] getWarnings()
Retrieve all warnings generated during the introspection of the class, or test creation. If a clearWarnings() call was ever made, then only those warnings that were encountered after the call will be returned.

Returns:
an array of all warnings generated while creating the test array.

clearWarnings

public void clearWarnings()
Remove all current warnings.


getTestMethods

public java.lang.reflect.Method[] getTestMethods()
Retrieve all public test methods discovered through inspection.

Returns:
all test methods.

getName

public java.lang.String getName()
Get the name of the test suite. By default, this is the class name.

Returns:
the name of the test suite.

getTestClass

public java.lang.Class getTestClass()
Get the class under test. This will never return null, and will always match the class passed into the constructor.

Returns:
the class under test.

testClass

protected boolean testClass(java.lang.Class theClass)
Discover if the given class is a valid testing class.

Parameters:
theClass - the class to parse for testing.
Returns:
true if the class is a public test class, otherwise false.

discoverTestMethods

protected void discoverTestMethods(java.lang.Class theClass)
Discover and record the test methods of the public test class theClass.

Parameters:
theClass - the class to parse for testing.

addTestMethod

protected void addTestMethod(java.lang.reflect.Method m,
                             java.util.Vector names)
Adds the method m to the inner list of known test methods, but only if it is a public test method.

Parameters:
m - the method to add.
names - a list of method names that have already been inspected.

isPublicTestMethod

protected boolean isPublicTestMethod(java.lang.reflect.Method m)
Asserts that the method is public, and that it is also a test method.

Parameters:
m - the method under scrutiny.
Returns:
true if m is a public test method, otherwise false.
See Also:
isTestMethod( Method )

isTestMethod

protected boolean isTestMethod(java.lang.reflect.Method m)
Test if method m is a test method, which means it accepts no parameters, returns void, and the name of the method begins with test.

Parameters:
m - the method under scrutiny.
Returns:
true if m is a public test method, otherwise false.

warning

protected void warning(java.lang.String message)
Adds a warning message to the inner list of warnings.

Parameters:
message - the message describing the warning.


Copyright © 2001-2003 by The GroboUtils Project