#4 Rethrow swallowed exceptions

closed
Urs Enzler
Core (4)
5
2009-03-12
2008-12-07
Urs Enzler
No

If there occurs an unexpected invocation exception then it should not be possible for tested code to swallow it (evil catch them all block).

Attached is a patch that rethrows such exceptions in the VerifyThatAllExpectationsHaveBeenMet method.

Note that this solution has a minor drawback: if the Verify method is in the TearDown of the unit test, the behaviour is not really stight forward anymore (stack trace does not point to the correct location because of the rethrow). Ideas?

Discussion

  • Urs Enzler
    Urs Enzler
    2008-12-07

    svn patch

     
  • Urs Enzler
    Urs Enzler
    2008-12-07

    svn patch - improved version that shows original stack trace

     
  • Urs Enzler
    Urs Enzler
    2008-12-07

    Uploaded a path that contains a better solution. It shows the original stack trace in the error message of the rethrown exception.

     
  • Urs Enzler
    Urs Enzler
    2008-12-07

    Oops, I made a mistake in the patch. There is a unit test that fails, but anyway, the code for rethrowing the exception is correct.

     
  • Urs Enzler
    Urs Enzler
    2009-01-06

    svn patch - with missing file

     
  • Urs Enzler
    Urs Enzler
    2009-01-06

    Uploaded patch that contains the missing test ;-)

     
  • Urs Enzler
    Urs Enzler
    2009-03-12

    • status: open --> closed