Results 1 to 6 of 6

Thread: QtTest- how to conditionally include/skip tests?

  1. #1
    Join Date
    Nov 2009
    Location
    US, Midwest
    Posts
    215
    Thanks
    62
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QtTest- how to conditionally include/skip tests?

    That's the question - how to conditionally include or skip the tests defined in the class slots? (other then moving them to be private members)?

    Thanks

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QtTest- how to conditionally include/skip tests?

    I would say the question should be clarified.
    What do you mean by conditionally?
    I know what you mean literally, but why would you want to have some tests not execute?
    I am not saying there is no good reason for it, but depending on the reason the correct way of doing it may differ.
    One way would be to have some tests in a different test suit and call that test suit only when you need it.
    Another way might be to give the test suit arguments that can be used in the code to execute only some tests.
    I probably could find some other way if I think further.
    It really depends on your needs and inclinations.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

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

    TorAn (31st May 2017)

  4. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QtTest- how to conditionally include/skip tests?

    First of all it should be stated whether the condition should be checked during compile or run time.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. The following user says thank you to wysota for this useful post:

    TorAn (3rd June 2017)

  6. #4
    Join Date
    Nov 2009
    Location
    US, Midwest
    Posts
    215
    Thanks
    62
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QtTest- how to conditionally include/skip tests?

    Sorry, it was not clear. During compile time. Currently I am just moving the test methods from slot specification to regular methods. Perhaps there is a better way.

  7. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QtTest- how to conditionally include/skip tests?

    #ifdef might be a good way but I think moc doesn't obey ifdefs unless you explicitly pass them to it via a commandline switch. What you can do though is put the #ifdef in body of the test and add/remove a QSKIP macro.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  8. #6
    Join Date
    Sep 2017
    Posts
    1
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QtTest- how to conditionally include/skip tests?

    Yes, you can conditionally skip tests using the QSKIP macro. The following provides an example to skip the database test if there is no database connection:
    http://doc.qt.io/qt-4.8/qtest.html#QSKIP

Similar Threads

  1. QtTest: forced to #include .cpp file
    By Urthas in forum Qt Programming
    Replies: 1
    Last Post: 1st August 2015, 03:00
  2. how to skip to read particular line in a file
    By iswaryasenthilkumar in forum Newbie
    Replies: 3
    Last Post: 6th April 2015, 09:40
  3. Skip NaN values in qwtplot
    By ivareske in forum Qwt
    Replies: 0
    Last Post: 12th October 2011, 15:01
  4. Replies: 7
    Last Post: 30th May 2011, 10:34
  5. skip function parameter
    By mattia in forum General Programming
    Replies: 4
    Last Post: 22nd November 2007, 16:55

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.