Open ridoo opened 10 years ago
for info: I added a DOCOMPARE makro which can compare the expected and the actual value, this is working at least for Qt and standard types....
@pokulo is it right that DOCOMPARE(actual, expected)
is the same than QVERIFY2(actual == expected, "the assertion failed")
?
the output of DOCOMPARE is much more advanced. You get the actual and the expected values printed to the error log, so no debugging of the TestSuite is necessary.
FAIL! : DomainTimeTests::construction() Compared values are not the same
Actual (dom->impliedValue(qVariantFromValue(t2)).value<Ilwis::Time>().toString()): 2009-04-12
Expected (QString("2009-04-13")): 2009-04-13
DOCOMPARE (QTest::qcompare(...)) is very strict about the type. Explicit type cast like this:
DOCOMPARE(fc->featureCount(),(unsigned int)0,"test features counted");
might be necessary. It uses equals operator (operator==) to compare.
We should agree on which kind of messages the
DOTEST
macro should accept!Currently a debug message describes the current test under execution while
QVERIFY2
just writes aFailure
if test assertion fails (see here).To me, writing the failure message only should be just fine as one gets only informed if something has failed (and then to take action!). Passed tests are fine but hide the actual important messages, i.e. failures.
Suggestion Change
DOTEST
macro to accept a failure message which is passed toQVERIFY2
to be written if assertion action fails only.