52North / IlwisTests

An c++ module containing tests for Ilwis development using Qt
5 stars 3 forks source link

DOTEST messages #1

Open ridoo opened 10 years ago

ridoo commented 10 years ago

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 a Failure 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 to QVERIFY2 to be written if assertion action fails only.

pokulo commented 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....

ridoo commented 10 years ago

@pokulo is it right that DOCOMPARE(actual, expected) is the same than QVERIFY2(actual == expected, "the assertion failed")?

pokulo commented 10 years ago

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.