Suite of tests. More...

#include <testsuite.hh>

Public Member Functions

void addSuite (const TestSuite &) throw (TestSuiteError)
 Adds a test suite to this test suite. More...
 
void addTest (TestCase *t) throw (TestSuiteError)
 Adds a test case to the suite of tests. More...
 
void free ()
 Deletes the tests. More...
 
string getName () const
 Returns name of test suite. More...
 
long getNumFailed () const
 Returns number of failed tests. More...
 
long getNumPassed () const
 Returns number of passed tests. More...
 
const ostream * getStream () const
 Returns output stream. More...
 
long report () const
 Prints a report on the number of passed and failed tests in the whole suite to the output stream. More...
 
void run ()
 Runs all test cases in the suite. More...
 
void setStream (ostream *osptr)
 Sets the output stream. More...
 
 TestSuite (const string &name, ostream *osptr=0)
 Constructor. More...
 

Private Member Functions

TestSuiteoperator= (const TestSuite &)
 Disallowed. More...
 
void reset ()
 
 TestSuite (const TestSuite &)
 Disallowed. More...
 

Private Attributes

string m_name
 
ostream * m_osptr
 
vector< TestCase * > m_tests
 

Detailed Description

Suite of tests.

Running a group of test cases is best be done by adding each test case to a test suite. This suite does then the run and report of the whole group.

Author
Chuck Allison, 2000. Doxygen comments by Philipp Frauenfelder, 2003.
See also
Chuck Allison, The Simplest Automated Unit Test Framework That Could Possibly Work, C/C++ Users Journal, September 2000.

Definition at line 41 of file testsuite.hh.

Constructor & Destructor Documentation

◆ TestSuite() [1/2]

test::TestSuite::TestSuite ( const string &  name,
ostream *  osptr = 0 
)
inline

Constructor.

Parameters
nameName of the test suite
osptrPointer to the output stream. Defaults to stdout.

Definition at line 85 of file testsuite.hh.

◆ TestSuite() [2/2]

test::TestSuite::TestSuite ( const TestSuite )
private

Disallowed.

Member Function Documentation

◆ addSuite()

void test::TestSuite::addSuite ( const TestSuite )
throw (TestSuiteError
)

Adds a test suite to this test suite.

◆ addTest()

void test::TestSuite::addTest ( TestCase t)
throw (TestSuiteError
)

Adds a test case to the suite of tests.

◆ free()

void test::TestSuite::free ( )

Deletes the tests.

◆ getName()

string test::TestSuite::getName ( ) const
inline

Returns name of test suite.

Definition at line 50 of file testsuite.hh.

◆ getNumFailed()

long test::TestSuite::getNumFailed ( ) const

Returns number of failed tests.

◆ getNumPassed()

long test::TestSuite::getNumPassed ( ) const

Returns number of passed tests.

◆ getStream()

const ostream* test::TestSuite::getStream ( ) const
inline

Returns output stream.

Definition at line 56 of file testsuite.hh.

◆ operator=()

TestSuite& test::TestSuite::operator= ( const TestSuite )
private

Disallowed.

◆ report()

long test::TestSuite::report ( ) const

Prints a report on the number of passed and failed tests in the whole suite to the output stream.

Returns
Number of failed tests.

◆ reset()

void test::TestSuite::reset ( )
private

◆ run()

void test::TestSuite::run ( )

Runs all test cases in the suite.

◆ setStream()

void test::TestSuite::setStream ( ostream *  osptr)
inline

Sets the output stream.

Definition at line 58 of file testsuite.hh.

Member Data Documentation

◆ m_name

string test::TestSuite::m_name
private

Definition at line 74 of file testsuite.hh.

◆ m_osptr

ostream* test::TestSuite::m_osptr
private

Definition at line 75 of file testsuite.hh.

◆ m_tests

vector<TestCase*> test::TestSuite::m_tests
private

Definition at line 76 of file testsuite.hh.


The documentation for this class was generated from the following file:
Page URL: http://wiki.math.ethz.ch/bin/view/Concepts/WebHome
21 August 2020
© 2020 Eidgenössische Technische Hochschule Zürich