JsUnit
Project Developer Home doxygen

Public Member Functions | Public Attributes | List of all members
ExceptionTestCase Class Reference

A TestCase that expects an exception of class mClass to be thrown. More...

Inheritance diagram for ExceptionTestCase:
Inheritance graph
Collaboration diagram for ExceptionTestCase:
Collaboration graph

Public Member Functions

void ExceptionTestCase (String name, Function clazz)
 Constructor. More...
 
- Public Member Functions inherited from TestCase
void TestCase (String name)
 Constructs a test case with the given name. More...
 
void tearDown ()
 Clear up the environment of the fixture. More...
 
void setUp ()
 Set up the environment of the fixture. More...
 
- Public Member Functions inherited from Assert
void Assert ()
 

Public Attributes

Function mClass
 Save the class. More...
 
- Public Attributes inherited from TestCase
int mName
 

Additional Inherited Members

- Protected Member Functions inherited from Test
virtual void Test ()
 
virtual String getName ()
 Retrieves the name of the test. More...
 
virtual Test findTest (String testName)
 Search a test by name. More...
 
virtual void setName (String testName)
 Sets the name of the test. More...
 
virtual Number countTestCases ()
 Counts the number of test cases that will be run by this test. More...
 
virtual TestResult run (TestResult result)
 Runs the test. More...
 

Detailed Description

A TestCase that expects an exception of class mClass to be thrown.

The other way to check that an expected exception is thrown is:

try {
  this.shouldThrow();
}
catch (ex) {
  if (ex instanceof SpecialException)
     return;
  else
     throw ex;
}
this.fail("Expected SpecialException");

To use ExceptionTestCase, create a TestCase like:

new ExceptionTestCase("testShouldThrow", SpecialException);

Constructor & Destructor Documentation

void ExceptionTestCase::ExceptionTestCase ( String  name,
Function  clazz 
)

Constructor.

The constructor is initialized with the name of the test and the expected class to be thrown.

Parameters
nameThe name of the test case.
clazzThe class to be thrown.

Member Data Documentation

Function ExceptionTestCase::mClass

Save the class.


The documentation for this class was generated from the following file:

JsUnit © 1999, 2000, 2001, 2002, 2003, 2006, 2007 by Jörg Schaible
Generated on Wed Apr 15 2015 02:33:07 for JsUnit by doxygen 1.8.5