View Full Version : testing with QTestLib
hyling
12th July 2007, 19:58
Hi,
I'm trying to figure out how to write test suites with QTestLib but if I have multiple test classes within a Visual Studio Project, only one of them gets compiled as an executable is there a way around this or do I have to have all my test cases in one class?
Thanks
Hua-Ying
Looks like one has to write main() on his own (instead of using QTEST_MAIN) to be able to use multiple test classes:
#include <QtTest>
class TestClassOne : public QObject
{
Q_OBJECT
private slots:
void testCase();
};
class TestClassTwo : public QObject
{
Q_OBJECT
private slots:
void testCase();
};
void TestClassOne::testCase()
{
qDebug() << "TestClassOne::testCase()";
}
void TestClassTwo::testCase()
{
qDebug() << "TestClassTwo::testCase()";
}
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
TestClassOne tc1;
TestClassTwo tc2;
return QTest::qExec(&tc1, argc, argv) ||
QTest::qExec(&tc2, argc, argv);
}
#include "main.moc"
hyling
12th July 2007, 20:37
Looks like one has to write main() on his own (instead of using QTEST_MAIN) to be able to use multiple test classes:
That makes sense... Thanks!
Hua-Ying
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.