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

 


TestSuite

Inherits from:
Declared In:

Overview

Named collection of unit tests.

Discussion

Test suites in CPlusTest are named collections of Tests (which can be both TestCases and other TestSuites). When a TestSuite is run, all of its component Tests are run. The order of Test execution within a TestSuite is undefined so you should not depend on it. There is a global TestSuite named "All" to which all instances of TestCase and TestSuite are added automatically; this can be accessed via the static TestSuite::allTests method. Generally, you will just want to create and use TestSuite instances rather than create subclasses. TestSuites do not currently create a fixture around execution of their Tests.



Functions

addTest
Adds a Test to the TestSuite, without taking ownership of it.
allTests
Gets a TestSuite named "All" containing all currently-instantiated TestCases and TestSuites.
name
Gets the name of the TestSuite.
removeTest
Removes a Test from the TestSuite, without deleting it.
run
Runs all of the Tests in the TestSuite against the given TestRun.
setUp
Overridden from Test.
tearDown
Overridden from Test.
tests
Gets all of the Tests in this TestSuite.
TestSuite
Constructor for the TestSuite class.
testWithName
Gets a Test in the TestSuite by name.
~TestSuite
Destructor for the TestSuite class.

addTest


Adds a Test to the TestSuite, without taking ownership of it.

public

virtual void addTest( Test *test);
Parameters
test
The Test to add to the TestSuite.
Discussion

Adds a Test to the TestSuite. The TestSuite does not take ownership of the Test; that is, it does not guarantee the Test will be deleted by the TestSuite's destructor or when the Test is removed from the TestSuite. This ensures it is safe to register global Tests with a TestSuite. No assumptions should be made regarding the order in which Tests are run.


allTests


Gets a TestSuite named "All" containing all currently-instantiated TestCases and TestSuites.

public

static TestSuite& allTests();
Return Value

Returns a TestSuite that will contain all currently-instanted TestCases and TestSuites.

Discussion

Gets a TestSuite containing all currently-instantiated TestCases and TestSuites. By default whenever a TestCase or a TestSuite is instantiated, it adds itself to the "All" TestSuite. This can be used as a simple way to run all unit tests. Always use this accessor to get the "All" TestSuite; do not cache it.


name


Gets the name of the TestSuite.

public

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

Returns the name of the TestSuite.

Discussion

Gets the name of the TestSuite.


removeTest


Removes a Test from the TestSuite, without deleting it.

public

virtual void removeTest( Test *test);
Parameters
test
The Test to remove from the TestSuite, which must be present within the TestSuite.
Discussion

Removes a Test from the TestSuite. Since the TestSuite never takes ownership of the Tests added to the TestSuite, removing a Test from a TestSuite does not result in the Test being deleted or its destructor being invoked. This ensures it is safe to register global Tests with a TestSuite.


run


Runs all of the Tests in the TestSuite against the given TestRun.

public

virtual void run( TestRun& run);
Parameters
run
The TestRun in which to record test progress, success, or failure.
Discussion

Runs all of the Tests in the TestSuite against the given TestRun, and records their success or failure. The TestSuite will run all of its Tests regardless of whether they succeed. No assumptions should be made regarding the order in which Tests are run.


setUp


Overridden from Test.

public

virtual void setUp();


tearDown


Overridden from Test.

public

virtual void tearDown();


tests


Gets all of the Tests in this TestSuite.

public

virtual std::list<Test*>& tests();
Return Value

Returns all of the Tests in this TestSuite.

Discussion

Gets all of the Tests in this TestSuite.


TestSuite


Constructor for the TestSuite class.

public

TestSuite( const std::string& name);
Parameters
name
The name of this test suite. It may be human-readable. The name "All" is reserved by the testing framework.
Discussion

Constructor for the TestSuite class. Configures the TestSuite to have the given name, and adds the TestSuite to the global TestSuite named "All" (accessed via TestSuite::allTests).


testWithName


Gets a Test in the TestSuite by name.

public

virtual Test* testWithName( const std::string& name);
Parameters
name
The name of the Test to find in the TestSuite.
Return Value

Returns the Test in the TestSuite with the given name, or NULL if no Test with the given name could be found.

Discussion

Locates a Test in the TestSuite given the name of the Test, and returns a pointer to it. If the Test is not found, NULL is returned.


~TestSuite


Destructor for the TestSuite class.

public

virtual ~TestSuite();
Discussion

Destructor for the TestSuite class. Removes the TestSuite from the global TestSuite named "All" (accessed via TestSuite::allTests).




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