Apple Developer Connection
Advanced Search
Member Login Log In | Not a Member? Contact ADC
ADC Home > Reference Library > Reference > Tools > Xcode > CPlusTest Reference

 


Test

Declared In:

Overview

Abstract base class for unit tests.

Discussion

Test is an abstract base class that defines a common interface for unit tests, both individual test cases and test suites. A test has a name and can be run against a TestRun, which is used to record the results of the test. Immediately before it is run a test will have a fixture set up (via setUp) and immediately after it is done running this fixture will be torn down (via tearDown).



Functions

name
Gets the name of the test.
run
Runs the test, recording the results.
setUp
Sets up any necessary state before a test is run.
tearDown
Tears down any state previously set up in setUp after a test has run.
Test
Plain constructor for the Test class.
~Test
Destructor for the Test class.

name


Gets the name of the test.

public

virtual const std::string& name() = 0;
Return Value

Returns the name of the test.

Discussion

Gets the name of the test. For test cases this is generally in standard C++ "class::method" format, while for test suites this is generally the name of the test suite class.


run


Runs the test, recording the results.

public

virtual void run( TestRun& run) = 0;
Parameters
run
A TestRun in which test success or failure is recorded.
Discussion

Runs the test and record the success or any failure information in the passed TestRun. This will invoke the test's setUp and tearDown methods around the actual invocation of the test.


setUp


Sets up any necessary state before a test is run.

public

virtual void setUp() = 0;
Discussion

Sets up any state needed by a test immediately before it is run. State used by a test should be set up here rather than in the test constructor so that it is only present when necessary.


tearDown


Tears down any state previously set up in setUp after a test has run.

public

virtual void tearDown() = 0;
Discussion

Tears down any state needed by a test immediately after it has run. State used by a test should be torn down here rather than in the test destructor so that it is only present as long as necessary.


Test


Plain constructor for the Test class.

public

Test();
Discussion

Plain constructor for the Test class. Does nothing, since Test is an abstract base class.


~Test


Destructor for the Test class.

public

virtual ~Test();
Discussion

Destructor for the Test class. Does nothing, since Test is an abstract base class.




Did this document help you?
Yes: Tell us what works for you.

It’s good, but: Report typos, inaccuracies, and so forth.

It wasn’t helpful: Tell us what would have helped.
Last Updated: 2008-03-11