Qt Test框架如何用于现实世界的项目?

时间:2015-06-15 03:03:48

标签: c++ qt unit-testing

来自其他测试框架,例如Google Test,我习惯于让所有测试同时运行,所有测试用例都在底部列出。虽然我设法找到一种方便地将所有测试类注册到单个可执行项目中的方法,但测试输出似乎根本不可维护。每个测试类运行都分组到控制台输出中的不同部分。如果您有100个测试类并且测试失败,您很快就会滚动以查找哪个测试失败。例如,对于两个测试类,我得到以下输出:

********* Start testing of Test_Rule *********
Config: Using QtTest library 5.4.2, Qt 5.4.2 (i386-little_endian-ilp32 shared (dynamic) debug build; by GCC 4.9.1)
PASS   : Test_Rule::initTestCase()
FAIL!  : Test_Rule::property_path() Crap
W:/GoogleDrive/Code/Dev/DanWatkins/Testbed/AutoCleaner/Tests/Test_Rule.h(20) : failure location
PASS   : Test_Rule::cleanupTestCase()
Totals: 2 passed, 1 failed, 0 skipped, 0 blacklisted
********* Finished testing of Test_Rule *********
********* Start testing of Test_AutoCleaner *********
Config: Using QtTest library 5.4.2, Qt 5.4.2 (i386-little_endian-ilp32 shared (dynamic) debug build; by GCC 4.9.1)
PASS   : Test_AutoCleaner::initTestCase()
PASS   : Test_AutoCleaner::cleanupTestCase()
Totals: 2 passed, 0 failed, 0 skipped, 0 blacklisted
********* Finished testing of Test_AutoCleaner *********

有没有办法让这个输出将每个测试类分组到同一个“run”调用中。理想情况下,示例看起来像这样:

********* Start testing of EVERYTHING *********
Config: Using QtTest library 5.4.2, Qt 5.4.2 (i386-little_endian-ilp32 shared (dynamic) debug build; by GCC 4.9.1)
PASS   : Test_Rule::initTestCase()
PASS   : Test_Rule::cleanupTestCase()

PASS   : Test_AutoCleaner::initTestCase()
PASS   : Test_AutoCleaner::cleanupTestCase()

FAIL!  : Test_Rule::property_path() Crap
W:/GoogleDrive/Code/Dev/DanWatkins/Testbed/AutoCleaner/Tests/Test_Rule.h(20) : failure location
Totals: 4 passed, 1 failed, 0 skipped, 0 blacklisted
********* Finished testing of EVERYTHING *********

注意我使用this blog post中的AutoTest类。该项目正在使用QMake。

0 个答案:

没有答案