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
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
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.
TorAn (31st May 2017)
First of all it should be stated whether the condition should be checked during compile or run time.
TorAn (3rd June 2017)
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.
#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.
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
Bookmarks