edu.byu.ece.edif.test
Class TestSuite

java.lang.Object
  extended by edu.byu.ece.edif.test.TestSuite

public class TestSuite
extends java.lang.Object

A test suite for testing the EDIF package. This class runs tests defined in classes that extend AbstractTestClass. Any methods annotated with

Version:
$Id: TestSuite.java 4 2008-04-16 22:31:52Z mrspud $
Author:
Jonathan Johnson

Nested Class Summary
private  class TestSuite.methodComparator
          A Comparator implementation to compare methods by their name so they can be sorted in alphabetical order.
 
Field Summary
private  java.lang.String _className
          The name of the TestClass currently being processed
private  TestStatus _currentResult
          Contains the current result of the current test method running.
private  java.util.Map _exceptionMap
          A Map containing the exceptions thrown by test methods.
private  java.lang.String _methodName
          The name of the test method currently being run
private  java.util.Collection _results
          A Collection of TestResult objects describing all test results
private  java.util.Collection _testClasses
          A Collection of TestClass objects which define tests to be run
 
Constructor Summary
TestSuite()
          Construct a new TestSuite for running tests.
 
Method Summary
 void addTest(java.lang.Class testClass)
          Add a new TestClass to the TestSuite.
protected  void assertEqual(java.lang.Object obj1, java.lang.Object obj2)
          Add an error if the passed in objects are not equal by the == operator.
 void assertFalse(boolean condition)
          Add an error if the passed in boolean is not false.
 void assertTrue(boolean condition)
          Add an error if the passed in boolean is not true.
 void assertUnequal(java.lang.Object obj1, java.lang.Object obj2)
          Add an error if the passed in objects are equal by the == operator.
 java.util.Map getExceptions()
           
 java.util.Collection run()
          Run tests in all the test classes that have been added to the TestSuite.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_className

private java.lang.String _className
The name of the TestClass currently being processed


_exceptionMap

private java.util.Map _exceptionMap
A Map containing the exceptions thrown by test methods. The key is a String representing the name of the Method that threw the exception. The value is a String describing the exception (stack trace and type).


_methodName

private java.lang.String _methodName
The name of the test method currently being run


_results

private java.util.Collection _results
A Collection of TestResult objects describing all test results


_currentResult

private TestStatus _currentResult
Contains the current result of the current test method running. This will be set to true at the beginning of each method run and only set to false if one the the assert methods of the test method fails.


_testClasses

private java.util.Collection _testClasses
A Collection of TestClass objects which define tests to be run

Constructor Detail

TestSuite

public TestSuite()
Construct a new TestSuite for running tests.

Method Detail

addTest

public void addTest(java.lang.Class testClass)
Add a new TestClass to the TestSuite.

Parameters:
testClass - the class to add to the TestSuite

getExceptions

public java.util.Map getExceptions()
Returns:
a Map containing any exceptions thrown by the test methods or null if no exceptions were thrown. The key is a String representing the name of the Method that threw the exception. The value is a String describing the exception (stack trace and type).

run

public java.util.Collection run()
Run tests in all the test classes that have been added to the TestSuite.

Returns:
a Collection of TestResult objects containing the results of the tests.

assertEqual

protected void assertEqual(java.lang.Object obj1,
                           java.lang.Object obj2)
Add an error if the passed in objects are not equal by the == operator.

Parameters:
obj1 - first object to compare
obj2 - second object to compare

assertFalse

public void assertFalse(boolean condition)
Add an error if the passed in boolean is not false.

Parameters:
condition - the boolean to test

assertTrue

public void assertTrue(boolean condition)
Add an error if the passed in boolean is not true.

Parameters:
condition - the boolean to test

assertUnequal

public void assertUnequal(java.lang.Object obj1,
                          java.lang.Object obj2)
Add an error if the passed in objects are equal by the == operator.

Parameters:
obj1 - first object to compare
obj2 - second object to compare