Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

ccunit::TestComponent Class Reference

Test Component Base Class. More...

#include <TestComponent.hh>

Inheritance diagram for ccunit::TestComponent:

ccunit::TestSuite ccunit::UnitTest ccunit::AutoTestSuite ComplexTest StackTest VoidTest List of all members.

Public Methods

 TestComponent (const string &name="(no name)")
 Simple ctor (accepts a name for the test component). More...

virtual ~TestComponent ()
 Destructor (does nothing). More...

virtual void Add (TestComponentPtr)
 add a component to a composite; simply return for a leaf. More...

virtual void Remove (TestComponentPtr)
 remove a component from a composite; simply return for a leaf. More...

virtual bool CheckRecursion (TestComponent *) const
 return true for attempts to add self to composite; return false for a leaf. More...

virtual void run ()
bool hasRun ()
 Have the tests been executed yet? (No results are available until the tests have been executed). More...

unsigned long getNumPassed ()
 Return number of successful tests (only valid after run). More...

unsigned long getNumFailed ()
 Return number of unsuccessful tests (only valid after run). More...

virtual void report (ostream &ostr)=0
 Print a report on an output stream. More...

virtual void reset ()
 Reset the pass/fail counters and the run flag. More...

void setName (const string &name)
 Set the name of this component. More...

const string & getName () const
 Get the name of this component. More...

void checkRun ()
 If the m_hasRun is false, run the tests (should set m_hasRun). More...

const list< ErrorReport > & getFailures () const
 get a reference to failure list. More...


Protected Methods

virtual void run_tests ()=0
 override this to actually run tests; call TestComponent::run() to execute tests. More...


Protected Attributes

unsigned long m_nPass
 number of tests which have succeeded. More...

unsigned long m_nFail
 number of tests which have failed. More...

bool m_hasRun
 flag indicated whether the tests have been run (i.e., tabulated test data is ready). More...

string m_name
 Test component name. More...

list< ErrorReportm_failures
 collect the failures for later reporting. More...


Friends

ostream & operator<< (ostream &ostr, TestComponentPtr my_test_component)
 Print the test results (calls report if not done already). More...

ostream & operator<< (ostream &ostr, TestComponent &my_test_component)
 Print the test results (calls report if not done already). More...


Detailed Description

Test Component Base Class.

#

Id:
TestComponent.hh,v 1.4 2002/04/02 20:21:05 canislupus Exp
#

The Test Component is the basic building block for writing Unit Tests and Suites. This class implements much of the shared functionality. From this class there are two derived classes; UnitTest, and TestSuite.

Author:
Dale K. Hawkins <dhawkins@cdrgts.com>
Header:
/cvsroot/libcctest/libccunit/src/TestComponent.hh,v 1.4 2002/04/02 20:21:05 canislupus Exp

Definition at line 33 of file TestComponent.hh.


Constructor & Destructor Documentation

ccunit::TestComponent::TestComponent const string &    name = "(no name)"
 

Simple ctor (accepts a name for the test component).

Definition at line 18 of file TestComponent.cc.

Referenced by CheckRecursion.

ccunit::TestComponent::~TestComponent   [virtual]
 

Destructor (does nothing).

Definition at line 27 of file TestComponent.cc.


Member Function Documentation

virtual void ccunit::TestComponent::Add TestComponentPtr    [inline, virtual]
 

add a component to a composite; simply return for a leaf.

Reimplemented in ccunit::AutoTestSuite.

Definition at line 89 of file TestComponent.hh.

References ccunit::TestComponentPtr.

virtual bool ccunit::TestComponent::CheckRecursion TestComponent *    const [inline, virtual]
 

return true for attempts to add self to composite; return false for a leaf.

Reimplemented in ccunit::TestSuite.

Definition at line 95 of file TestComponent.hh.

References TestComponent.

void ccunit::TestComponent::checkRun  
 

If the m_hasRun is false, run the tests (should set m_hasRun).

Definition at line 61 of file TestComponent.cc.

References m_hasRun, and run.

Referenced by getNumFailed, getNumPassed, ccunit::UnitTest::report, and ccunit::TestSuite::report.

const list<ErrorReport>& ccunit::TestComponent::getFailures   const [inline]
 

get a reference to failure list.

Definition at line 140 of file TestComponent.hh.

References m_failures.

const string& ccunit::TestComponent::getName   const [inline]
 

Get the name of this component.

Definition at line 134 of file TestComponent.hh.

References m_name.

Referenced by main.

unsigned long ccunit::TestComponent::getNumFailed  
 

Return number of unsuccessful tests (only valid after run).

Definition at line 79 of file TestComponent.cc.

References checkRun, and m_nFail.

Referenced by main.

unsigned long ccunit::TestComponent::getNumPassed  
 

Return number of successful tests (only valid after run).

Definition at line 72 of file TestComponent.cc.

References checkRun, and m_nPass.

Referenced by main.

bool ccunit::TestComponent::hasRun  
 

Have the tests been executed yet? (No results are available until the tests have been executed).

Definition at line 55 of file TestComponent.cc.

References m_hasRun.

virtual void ccunit::TestComponent::Remove TestComponentPtr    [inline, virtual]
 

remove a component from a composite; simply return for a leaf.

Reimplemented in ccunit::TestSuite.

Definition at line 92 of file TestComponent.hh.

References ccunit::TestComponentPtr.

virtual void ccunit::TestComponent::report ostream &    ostr [pure virtual]
 

Print a report on an output stream.

Implemented in ccunit::TestSuite.

void ccunit::TestComponent::reset   [virtual]
 

Reset the pass/fail counters and the run flag.

Reimplemented in ccunit::TestSuite.

Definition at line 86 of file TestComponent.cc.

References m_failures, m_hasRun, m_nFail, and m_nPass.

Referenced by run.

void ccunit::TestComponent::run   [virtual]
 

Execute the tests, reporting failures on ostr. Sets the m_hasRun flag.

See also:
report run

Definition at line 46 of file TestComponent.cc.

References m_hasRun, reset, and run_tests.

Referenced by checkRun, and main.

virtual void ccunit::TestComponent::run_tests   [protected, pure virtual]
 

override this to actually run tests; call TestComponent::run() to execute tests.

Implemented in StackTest.

Referenced by run.

void ccunit::TestComponent::setName const string &    name [inline]
 

Set the name of this component.

Definition at line 131 of file TestComponent.hh.

References m_name.


Friends And Related Function Documentation

ostream& operator<< ostream &    ostr,
TestComponent &    my_test_component
[friend]
 

Print the test results (calls report if not done already).

Definition at line 104 of file TestComponent.cc.

ostream& operator<< ostream &    ostr,
TestComponentPtr    my_test_component
[friend]
 

Print the test results (calls report if not done already).

Definition at line 96 of file TestComponent.cc.


Member Data Documentation

list<ErrorReport> ccunit::TestComponent::m_failures [protected]
 

collect the failures for later reporting.

Definition at line 162 of file TestComponent.hh.

Referenced by ccunit::UnitTest::do_fail, getFailures, ccunit::UnitTest::report, and reset.

bool ccunit::TestComponent::m_hasRun [protected]
 

flag indicated whether the tests have been run (i.e., tabulated test data is ready).

Definition at line 156 of file TestComponent.hh.

Referenced by checkRun, hasRun, ccunit::UnitTest::report, reset, run, and ccunit::TestSuite::run_tests.

string ccunit::TestComponent::m_name [protected]
 

Test component name.

Definition at line 159 of file TestComponent.hh.

Referenced by getName, and setName.

unsigned long ccunit::TestComponent::m_nFail [protected]
 

number of tests which have failed.

Definition at line 153 of file TestComponent.hh.

Referenced by ccunit::UnitTest::do_fail, getNumFailed, ccunit::UnitTest::report, reset, and ccunit::TestSuite::run_tests.

unsigned long ccunit::TestComponent::m_nPass [protected]
 

number of tests which have succeeded.

Definition at line 150 of file TestComponent.hh.

Referenced by ccunit::UnitTest::_succeed, getNumPassed, ccunit::UnitTest::report, reset, and ccunit::TestSuite::run_tests.


The documentation for this class was generated from the following files:
Generated on Tue Apr 2 15:33:26 2002 for libccunit by doxygen 1.2.14 written by Dimitri van Heesch, © 1997-2002

Project hosted on sourceforge SourceForge Logo