Results 1 to 3 of 3

Thread: Proper Test Suite example

  1. #1
    Join Date
    Jun 2006
    Posts
    43
    Thanks
    9
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Proper Test Suite example

    This question crosses the boundary between qmake and code.

    I'm having some trouble getting my head around the correct use of "CONFIG += testcase".

    All the examples show to make a single "Test Case" object in a source file and then add the

    Qt Code:
    1. QTEST_MAIN(TestCaseClassname)
    2. #include "testcasefilename.moc"
    To copy to clipboard, switch view to plain text mode 

    This doesn't allow for multiple test cases in one executable though, since it creates main functions.


    Isn't it possible to write a "Test Suite", defined as a collection of test cases, that runs all the cases in single executable?
    If so, doesn't "CONFIG += testcase" do this somehow so it can trigger with "make check"?
    Is there a decent example somewhere?

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Proper Test Suite example

    The concept followed by QTestLib (and many other Unittesting frameworks) is to isolate the tests for each unit into one executable.
    Makes it less likely that tests interfere with each other, rebuilds tests only for changed units, can build and run tests even if other units currently don't compile, etc.

    You can add a custom target to the .pro file of the unittest directory which then calls each test.
    See https://github.com/KDAB/KDSoap/blob/.../unittests.pro for example.

    Cheers,
    _

  3. #3
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Proper Test Suite example

    It is even easier than that!

    Just found this http://doc.qt.io/qt-5/qmake-common-p...ing-a-testcase

    Cheers,
    _

Similar Threads

  1. Unit Test: Test if QPushButton has a menu
    By FelixB in forum Qt Programming
    Replies: 1
    Last Post: 7th November 2012, 12:12
  2. Replies: 3
    Last Post: 9th July 2012, 16:22
  3. Replies: 2
    Last Post: 14th June 2012, 08:06
  4. qt on VS2005 team suite
    By giginjose in forum Newbie
    Replies: 0
    Last Post: 6th May 2010, 13:19
  5. Test suite for Qt api
    By r1z0r in forum Newbie
    Replies: 5
    Last Post: 9th September 2009, 19:09

Tags for this Thread

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.