robotology / robot-testing-framework

Robot Testing Framework (RTF)
http://robotology.github.io/robot-testing-framework/index.html
GNU Lesser General Public License v2.1
19 stars 11 forks source link

modify RTF_TEST_CHECK so that it always prints the string and report success/failure #34

Closed lornat75 closed 9 years ago

lornat75 commented 9 years ago

E.g.:

RTF_TEST_CHECK(value, "checking value")

should be logged as:

checking value...OK

or

checking value... NOT OK

At the moment the macro prints the string only if the tests fails.

lornat75 commented 9 years ago

@traversaro @randaz81 @valegagge

apaikan commented 9 years ago

I doubt which message user should include in RTF_TEST_CHECK; i.e. reports the cause of failure or a comment on what has been checked. For example:

bool ret = yarp::os::Network::connect("/port1", "/port2");
RTF_TEST_CHECK(ret, "connecting two ports.");    // what was the reason of failure?

or

bool ret = yarp::os::Network::connect("/port1", "/port2");
RTF_TEST_CHECK(ret, "cannot connect two ports because blablabla..." ); 

for now this can be solved by using two different macros (maybe not very convenient):

RTF_TEST_REPORT("connecting two ports.");
bool ret = yarp::os::Network::connect("/port1", "/port2");
RTF_TEST_CHECK(ret, "cannot connect two ports because blablabla..." ); 

The RTF_TEST_CHECK macro has been used in many different test cases and changing it may needs changes to some of the tests implementation :s What about introducing another macro which aggregate both (comment and cause of failure) ?

lornat75 commented 9 years ago

I vote for the first option because you rarely know why a test fails but you do known what you are testing.

I think we just need to extend the macro so that it always reports the result of the test (either success or fail).

apaikan commented 9 years ago
RTF_TEST_CHECK(2<3, "two is less than three");

will result:

[INFO]  (MyTest) checks: two is less than three
RTF_TEST_CHECK(2==3, "two is equal to three");

will result:

[FAIL]  (MyTest) checks: two is equal to three