Menu

#9 No logging of the exception throw

open-accepted
None
5
2014-05-01
2010-05-22
No

When an exception is thrown within TEST_ASSERT then the whole function is reported as 0% successful. However, there is no information about what is the reason of 0% result and at what line the exception is thrown which makes fixing the problem harder.
I propose to change TEST_ASSERT to add information to the report that unexpected exception is thrown and log also the line and file where the TEST_ASSERT is invoked.

Discussion

  • Nate Gallaher

    Nate Gallaher - 2010-05-24
    • assigned_to: nobody --> ngallaher
    • status: open --> open-accepted
     
  • Nate Gallaher

    Nate Gallaher - 2010-05-24

    Good catch . The fix to this will be part of a larger fix to exception handling, which we only do minimally at this point.

     
  • Philip Wardlaw

    Philip Wardlaw - 2014-05-01

    Has anything been done on this bug? I don't mind if there is no rigorous exception handling, but printing out e.what() would be very beneficial. It is very confusing for developers when a test fails due to an exception, and there is no output explaining this from CppTest.

     
  • Sebastian Pipping

    I might find time to review patches, but that's all, I'm afraid.

     
  • Philip Wardlaw

    Philip Wardlaw - 2014-05-01

    I can suggest the following fix, Although it may not work for more sophisticated outputs (html etc.)

    Modify lines 180 of src/suite.cpp onwards as follows:

    catch (std::exception& e) {
        std::cout <<  "\tError:   An exception was thrown during test '" << data._name <<"()'" <<  std::endl;
        std::cout << "\tDetails: " << e.what() <<  std::endl;
        _suite._result = _suite._success = false;
    }
    

    Text output:

    SolutionVariableTest: 3/4
    Error: An exception was thrown during test 'testSolMap()'
    Details: You have already added a SolutionVariable of corresponding VariableNames type to SolutionMap
    SolutionVariableTest: 4/4
    SolutionVariableTest: 4/4, 75% correct in 0.000466 seconds

    I understand that output should be done via _suite._output. Perhaps class Output should have a new public function exception(testName, msg).

     

    Last edit: Philip Wardlaw 2014-05-01

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.