简单的QTest测试
qmake 4.8.1
1) 创建TestBar目录.
2) 编辑TestBar.cpp文件.
- #include
- {
- Q_OBJECT
- private slots:
- void toUpper();
- };
- void TestBar::toUpper()
- {
- QVERIFY(1==1);
- }
- QTEST_MAIN(TestBar)
- #include "TestBar.moc" /* 这里需要根据Makefile中的testbar.moc来修改,如果是小写则改为小写 */
3) qmake -project "CONFIG += qtestlib"
4) qmake
5) make
********* Start testing of TestBar *********
Config: Using QTest library 4.8.1, Qt 4.8.1
PASS : TestBar::initTestCase()
PASS : TestBar::toUpper()
PASS : TestBar::cleanupTestCase()
Totals: 3 passed, 0 failed, 0 skipped
********* Finished testing of TestBar *********