我正在使用QTestLib库和QTest来运行我的单元测试。我正在使用Windows 7并使用Qt 4.8与MVSC 2010编译器。 当我运行使用我的测试:如何在测试失败时从QTestLib/QTest获取信息
QTest::qExec(TestDateDD/whateverTestClass);
我得到在控制台输出:
********* Start testing of TestDateDD *********
Config: Using QTest library 4.8.0, Qt 4.8.0
PASS : TestDateDD::initTestCase()
PASS : TestDateDD::testValidity()
FAIL! : TestDateDD::testMonth(2012/7/10) Compared values are not the same
Actual (date.longMonthName(date.month())): July
Expected (monthname): June
..\UnitTestingPlugiin\TestDateDD.cpp(38) : failure location
PASS : TestDateDD::cleanupTestCase()
Totals: 3 passed, 1 failed, 0 skipped
********* Finished testing of TestDateDD *********
但是我的要求是在我的GUI对每个测试槽,以显示此消息。我做了一些研究,发现qtestlog.cpp使用它自己的messageHandler来管理测试输出,并将结果显示为PASS或FAIL,并显示失败消息,行号等。有没有什么办法可以处理这个QTest的messageHandler用于我的GUI应用?
感谢您的建议,我现在能够将我的测试结果写入xml文件,然后从中读取。 – SAM