Separate Test Classes

When testing

    class class_that_really_gets_used {
    };

create a separate class to test it:

    class test_class_that_really_gets_used {
    public:
        void test() {
           class_that_really_gets_used object;
           TEST_ASSERT( object.property() );
        }
    };

If necessary, make the test class a friend of the first class to provide access to private member variables.

(Accessing private data is often a great convenience for testing.)

Similarly, separate VoidFuncTest void free function tests.


EditText of this page (last edited November 6, 2002) or FindPage with title or text search