In general, the macros QVERIFY
, QCOMPARE
, etc. shall not be used outside a test function. The reason is, that in case of a failure, they interrupt the test with a return
.
If I want to do tests in a function, I should do them by hand and return false if one of them fails. Then call the function with QVERIFY
. But when I do this, I miss out the detailed output of the macros like the line where the error occurred.
So I'm looking for a way to use the macros outside of a test function. One solution is to create my own macro that interrupts the test when a macro call in the underlying function fails. The main problem here is to detect when a test has failed. Looking into Qt's code, in case of a fail the variable QTest::failed
is set to true
. But I don't have access to this variable.
Is there a way to find out if a QtTest macro has failed?