TestSuiteBuilder

   
TestSuiteBuilder

Description

The template class TestSuiteBuilder (see Figure C-32) is a helper class used to add tests to a TestSuite . It is used by the macros CPPUNIT_TEST_SUITE( ) and CPPUNIT_TEST_SUITE_END( ) .

TestSuiteBuilder belongs to the namespace CppUnit . It is declared and implemented in the file extensions/TestSuiteBuilder.h .

Figure C-32. The template class TestSuiteBuilder
figs/utf_ac32.gif

Declaration

 template<typename Fixture> class TestSuiteBuilder 

Constructors/Destructors


TestSuiteBuilder(TestSuite *suite)

Constructs a TestSuiteBuilder for a TestSuite .


TestSuiteBuilder(string name )

Constructs a TestSuiteBuilder and a new TestSuite with the given name.

Public Methods


void addTest(Test *test)

Adds test to the TestSuite .


void addTestCaller(string methodName, TestMethod testMethod)

Adds a TestCaller that calls the TestMethod .


void addTestCaller(string methodName, TestMethod testMethod, Fixture *fixture)

Adds a TestCaller that calls the TestMethod in the context of the Fixture .


template<typename ExceptionType>

void addTestCallerForException(string methodName, TestMethod testMethod, Fixture *fixture, ExceptionType *dummyPointer)

A template function to add a TestCaller that calls the TestMethod in the context of the Fixture . The TestMethod is expected to throw an Exception of type ExceptionType .


string makeTestName(const string &methodName)

Returns a test name that incorporates the TestSuite name and methodName .


TestSuite *suite( ) const

Returns the TestSuite for this TestSuiteBuilder .


TestSuite *takeSuite( )

Takes ownership of the TestSuite from the smart pointer m_suite .

Protected/Private Methods


TestSuite(const TestSuite &other)

A copy constructor declared private to prevent its use.


TestSuite& operator=(const TestSuite &other)

A copy operator declared private to prevent its use.

Attributes


std::auto_ptr<TestSuite> m_suite

A smart pointer to the TestSuite for this TestSuiteBuilder ( private ).



Unit Test Frameworks
Unit Test Frameworks
ISBN: 0596006896
EAN: 2147483647
Year: 2006
Pages: 146
Authors: Paul Hamill

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net