TipsAndTricks

  • For a simple (and free!) way of calculating test coverage with C and C++ programs, have a look at gcov, the GNU test coverage program: http://gcc.gnu.org/onlinedocs/gcc-3.0/gcc_8.html

  • The return value from the test program is the number of test failures - i.e. if all the tests pass, the program will return 0; if three tests fail, the program will return 3; etc. This can be handy in makefiles, scripts, etc.

  • You can use global variables in your tests/suites:

    #include "tests.h"

    START_SUITE(mySuite)

    MyVariable *var;

    START_TEST("myTest")
    ... lots of tests, one which sets var ...
    END_TEST("myTest")

    START_TEST("printVar")
    var->print();
    END_TEST()

    delete(var);

    END_SUITE()

  • Powered by Wiki! and
    SourceForge.net Logo