class Test

Abstract interface for all kinds of unit tests.

This abstract class defines all the operations which a test must support to be used for unit testing. The only attribute it defines is the name of the test.



Public Members:
    Test (const string& name) ;
    Basic constructor.
    Only sets the name.

    virtual ~Test () ;
    Destructor.
    Ensures that all derived classes have a virtual destructor.

    virtual string getName () const ;
    Returns the name of the test.
    The name of the test could only be set when an test object is created. It should at least be unique within a test suite.

    virtual bool run (TestConductor&) ;
    Delegate the execution of the test to a test conductor.
    This operation is used to tell the test that it should run itself with the help of the given test conductor. This operation could be used to prepare for execution by a conductor. Normally, this operation simply calls the conductor to execute the test. Unit test classes that perform actual test actions should not override this method. It returns true if the test was successfully executed, otherwise false.

    virtual void setUp () ;
    Set-up the test fixture.
    This operation is called by the test conductor so that the test can prepare itself for execution. If that operation fails, neither the test operation nor the tearDown function is called!

    virtual void test (TestConductor&) ;
    Execute the test.
    This method should perform the test of some application domain functionality, either directly or indirectly. Test cases should do the actual testing here, test suites should iterate over their contents when this method is called. In case something doesn't behave as expected, an exception should be thrown. Otherwise the function simply returns.

    virtual void tearDown () ;
    Tear-down of the test fixture.
    After the test was executed, this member function is called to tear down the test fixture, i.e. freeing previously allocated resources. This operation is executed whether the test action was successful or not.

    virtual bool isTestCase () const ;
    Check if the test is a test case.
    Returns true when the test instance itself tests some application domain functionality.

    virtual int noTestCases () const ;
    Returns the number of contained test cases.
    Computes the total amount of directly or indirectly included test cases, including the called instance itself.

    virtual int noTestSuites () const ;
    Returns the number of contained test suites.
    Computes the total amount of directly or indirectly included test suites, including the called instance itself.

    virtual void put (ostream&) const ;
    Write a string representation of the test to an output stream.
    Support function for the (non-virtual) output stream operator <<.




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