Results 1 to 3 of 3

Thread: testing with QTestLib

  1. #1
    Join Date
    Oct 2006
    Location
    Raleigh, NC
    Posts
    11
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default testing with QTestLib

    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

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: testing with QTestLib

    Looks like one has to write main() on his own (instead of using QTEST_MAIN) to be able to use multiple test classes:
    Qt Code:
    1. #include <QtTest>
    2.  
    3. class TestClassOne : public QObject
    4. {
    5. Q_OBJECT
    6.  
    7. private slots:
    8. void testCase();
    9. };
    10.  
    11. class TestClassTwo : public QObject
    12. {
    13. Q_OBJECT
    14.  
    15. private slots:
    16. void testCase();
    17. };
    18.  
    19. void TestClassOne::testCase()
    20. {
    21. qDebug() << "TestClassOne::testCase()";
    22. }
    23.  
    24. void TestClassTwo::testCase()
    25. {
    26. qDebug() << "TestClassTwo::testCase()";
    27. }
    28.  
    29. int main(int argc, char *argv[])
    30. {
    31. QApplication app(argc, argv);
    32. TestClassOne tc1;
    33. TestClassTwo tc2;
    34. return QTest::qExec(&tc1, argc, argv) ||
    35. QTest::qExec(&tc2, argc, argv);
    36. }
    37.  
    38. #include "main.moc"
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  3. The following user says thank you to jpn for this useful post:

    hyling (12th July 2007)

  4. #3
    Join Date
    Oct 2006
    Location
    Raleigh, NC
    Posts
    11
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: testing with QTestLib

    Quote Originally Posted by jpn View Post
    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

Similar Threads

  1. GUI runner of QTestLib
    By Intaek Lim in forum Qt-based Software
    Replies: 1
    Last Post: 25th April 2007, 08:06
  2. Testing a custom Plugin
    By maluta in forum Qt Programming
    Replies: 5
    Last Post: 31st October 2006, 15:09
  3. QTest Unit Testing
    By bothapn in forum Qt Programming
    Replies: 1
    Last Post: 16th July 2006, 22:11
  4. testing and testcases
    By sreedhar in forum Qt Programming
    Replies: 3
    Last Post: 7th June 2006, 15:26

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.