CppUnit project page FAQ CppUnit home page

Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

Protector Class Reference

Protects one or more test case run. More...

#include <Protector.h>

Inheritance diagram for Protector:

DefaultProtector ProtectorChain List of all members.

Public Member Functions

virtual ~Protector ()
virtual bool protect (const Functor &functor, const ProtectorContext &context)=0

Protected Member Functions

void reportError (const ProtectorContext &context, const Exception &error) const
void reportError (const ProtectorContext &context, const Message &message, const SourceLine &sourceLine=SourceLine()) const
void reportFailure (const ProtectorContext &context, const Exception &failure) const
Message actualMessage (const Message &message, const ProtectorContext &context) const

Detailed Description

Protects one or more test case run.

Protector are used to globably 'decorate' a test case. The most common usage of Protector is to catch exception that do not subclass std::exception, such as MFC CException class or Rogue Wave RWXMsg class, and capture the message associated to the exception. In fact, CppUnit capture message from Exception and std::exception using a Protector.

Protector are chained. When you add a Protector using TestResult::pushProtector(), your protector is in fact passed as a Functor to the first protector of the chain.

TestCase protects call to setUp(), runTest() and tearDown() by calling TestResult::protect().

Because the protector chain is handled by TestResult, a protector can be active for a single test, or a complete test run.

Here are some possible usages:


Constructor & Destructor Documentation

Protector::~Protector  )  [virtual]
 


Member Function Documentation

Message Protector::actualMessage const Message message,
const ProtectorContext context
const [protected]
 

virtual bool Protector::protect const Functor functor,
const ProtectorContext context
[pure virtual]
 

Implemented in DefaultProtector, and ProtectorChain.

void Protector::reportError const ProtectorContext context,
const Message message,
const SourceLine sourceLine = SourceLine()
const [protected]
 

void Protector::reportError const ProtectorContext context,
const Exception error
const [protected]
 

void Protector::reportFailure const ProtectorContext context,
const Exception failure
const [protected]
 


The documentation for this class was generated from the following files:
SourceForge Logo hosts this site. Send comments to:
CppUnit Developers