05-24-2012 12:05 PM
You have a choice.
You likely want to use QtTest.
You could also use boost, googletest, CppUnit or others.
QtTest is bundled with Qt and lets you run tests with signal dispatching.
You need to add to your qmake project file:
QT += testlib
You can define a class for your test, e.g.:
class TestMyObject: public QObject
and tests e.g.
In main, TestMyObject test1; QTest::qExec(&test1, argc, argv);
This is where the 2nd link comes in: you'll want it so you can easily run a suite of tests. Your code will just have #include "AutoTest.h" .... DECLARE_TEST(TestMyObject); and AutoTest::run(argc, argv).