class TestManager : TestConductor, TestSession

Implementation of the unit test execution logic.

This class implements the mechanism for executing tests, including both test cases and test suites. It isolates the execution of fixture set-up, test execution and fixture tear-down operations. That guarantees proper execution of complex hierarchies of test suites and test cases. Each phase of a test execution is directed through all registered call gates. Their main purpose is to transform domain exceptions into test failures or test errors. Last but not least, all kind of states of test execution are reported to all enabled test observers.



Public Members:
    TestManager (bool recordExceptions = true) ;
    Default constructor
    Sets the internal state so that a test suite could be executed by the manager. if recordExceptions is true, all TestException instances are recorded internally. Most TestObserver implementations rely on the fact that exceptions are recorded by the manager. This feature should only be disabled in special cases when huge amounts of test cases must be executed and special test observers are used.

    virtual ~TestManager () ;
    Default destructor
    Deletes all call gates that should be released and frees all test exception records.

    virtual bool execute (Test&) ;
    Execute a test.
    This method handles the execution of a single test, most likely a test suite. Used by test case and test suite implementations. External users of this class should use conduct to start a test session.

    virtual void skip (Test&) ;
    A test is skipped.
    The internal bookkeeping is updated and the event is logged.

    virtual void addCallGate (CallGate* gate) ;
    Adds a call gate.
    The call gate is deleted when the manager is destroyed.

    virtual void removeCallGate (CallGate* gate) ;
    Removes a call gate.
    The call gate is romoved if it was registered.

    virtual int noEncountered () const ;
    Returns the number of test that the manager has encountered do far.
    The number of encountered test is the number of the executed tests plus the number of test that were skipped. This function is useful for progress reporting.

    virtual int noExecuted () const ;
    The number of executed tests.
    Equal to the number of succeeded and failed tests.

    virtual int noPassed () const ;
    The number of test that went fine.
    Reader method.

    virtual int noFailed () const ;
    The number of test that generated a test failure or a test error.
    Note that this number is different from what is returned by noFailures and noErrors.

    virtual int noSkipped () const ;
    The number of test that were skipped.
    This is the number of test that were deliberately not executed.

    virtual int noFailures () const ;
    The number of test failures generated so far.
    This is the number of test failures, not the number of unsuccessful tests! (see also noFailed).

    virtual int noErrors () const ;
    The number of test errors encountered so far.
    Note that one test can generate two test errors! One error could come from a test action and another one from an erroneous test fixture tear-down.

    virtual vector<TestExceptionRecord*>& getTestExceptions () ;
    Returns the all test exceptions generated during execution of a test suite
    The returned vector should not be altered.

    virtual void reset () ;
    Resets the manager to its initial state.
    This function must be called when a manager instance is reused for conducting the execution of another test session.

    virtual void conduct (Test&) ;
    Conduct the execution of a test session.
    This operation must be called by the client to execute a test session (a test suite or even only a single test case) under control of the test manager.

    virtual bool supportsCancel () const ;
    Check if cancelling test sessions is supported.
    To figure out whether that is possible or not, all active observers are asked if they permit cancel. Only when all active observer permit cancelling test sessions, true is returned.

    virtual bool tryCancel () ;
    Try to cancel executing tests.
    Invoking this functions makes the manager immediately stop all test activities and return to the caller which invoked the conduct operation. This function should only be called from functions invoked through the test manager (i.e. in endTest or logException).

    TestPhase getCurrentTestPhase () ;
    Inquires the current execution state of the actual test.
    This function tells the caller in which phase of a test execution the session is currently in.

    virtual time_t getStartTime () const ;
    Returns the start time of the session.
    See TestSession for details.

    virtual time_t getStopTime () const ;
    Returns the session stop time.
    See TestSession for details.

    virtual void getRunTime (time_t& sec, long& usec) const ;
    Returns the run time of the test session.
    See TestSession for details.

    virtual void addObserver (TestObserver* observer) ;
    Add a test observer.
    The observer is added to the set of registered test observers, which is equal to the set to the set of active test observers before function configureFrom is called.

    virtual void removeObserver (TestObserver* observer) ;
    Removes a test observers.
    The observer is removed from the set of registered (and active) test observers.

    void configureFrom (ArgVector& args) ;
    The test manager and all registered observers are configured.
    For every registered test observer configureFrom is called as well. Only when this returns true, the observer remains active. Note that this functions could modify the contents of args! So if the argument vector should be used more than once, a copy must be used here.

    virtual void takeFixture (TestFixture* fixture) ;
    Take a test fixture.
    The fixture is owned by the test manager after calling this function, so the fixture is deleteled when the manager is deleted.




Friends:
    friend class ExecutionGate ;
    Test manager internal class for controlling the execution of a test.
    This inner class of test manager actually implements the execution of a test. Not meant to be used or subclassed by test drivers.




The Scrunitizer C++ Unit Test Framework
by Bernd Linowski

[Scrunitizer]  [Overview]  [Cookbook]  [Download]  [Index]  [Linosphere]

Page generated: 1 Nov 2000
(C) by Bernd Linowski
scrunitizer@linosphere.de