JsUnit
Project Developer Home doxygen

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

A test case defines the fixture to run multiple tests. More...

Inheritance diagram for TestCase:
Inheritance graph
Collaboration diagram for TestCase:
Collaboration graph

Public Member Functions

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

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 test case defines the fixture to run multiple tests.

To define a test case

  1. implement a subclass of TestCase
  2. define instance variables that store the state of the fixture
  3. initialize the fixture state by overriding setUp
  4. clean-up after a test by overriding tearDown. Each test runs in its own fixture so there can be no side effects among test runs.

For each test implement a method which interacts with the fixture. Verify the expected results with assertions specified by calling assertTrue with a boolean or one of the other assert functions.

Once the methods are defined you can run them. The framework supports both a static and more generic way to run a test. In the static way you override the runTest method and define the method to be invoked. The generic way uses the JavaScript functionality to enumerate a function's methods to implement runTest. In this case the name of the case has to correspond to the test method to be run.

The tests to be run can be collected into a TestSuite. JsUnit provides several test runners which can run a test suite and collect the results. A test runner expects a function FileNameSuite as the entry point to get a test to run.

See Also
TestResult
TestSuite

Constructor & Destructor Documentation

void TestCase::TestCase ( String  name)

Constructs a test case with the given name.

Parameters
nameThe name of the test case.

Member Function Documentation

void TestCase::setUp ( )

Set up the environment of the fixture.

void TestCase::tearDown ( )

Clear up the environment of the fixture.

Member Data Documentation

int TestCase::mName

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