Details
-
Task
-
Resolution: Unresolved
-
Not Evaluated
-
None
-
None
-
None
Description
QVERIFY and QCOMPARE macros can only be used in functions returning void; In more complex test cases a test might want to use these macros also in non void functions.
See for example this test: https://codereview.qt-project.org/#/c/153336/22/tests/auto/qx11info/tst_qx11info.cpp
It would be nice if we could set arbitrary "exit functions" for macros , e.g. "return;" (default), "return false", "close()" (as in QWindow);
This missing feature becomes more important now with an introduction of lambdas in C++: In the same example code, instead of writing :
obj->m_foundFirstEventAgain = true;
It would be cleaner just to add QFAIL macro there, that calls QWindow::close();
This would need to be looked at properly, maybe there are better alternatives to macros.
Attachments
Issue Links
- relates to
-
QTBUG-63146 qtestlib: cleanups, re-design, API completeness and documentation
- Reported
-
QTBUG-19615 [autotests] Some tests use QVERIFY and friends outside of test functions
- Open
-
QTBUG-66320 Provide a way to conveniently use test helper functions with qtestlib
- Open