Catch2: Dealing with failure: assertions/terminate

Right now there aren’t any documented ways of checking that my program fails correctly when no exceptions are involved. In particular, calls to std::terminate and to assert() (in debug mode only, i.e. when NDEBUG is not defined).

In google-test one can do: EXPECT_DEATH/EXPECT_DEBUG_DEATH to test for failure in general and failure in debug mode only as well as to test that the correct failure message is printed (although for asserts I always write a regexp that catches everything).

Note: a workaround is to define your ASSERT macro to throw an exception and hope that no-one catches it. But this is just a workaround.

About this issue

  • Original URL
  • State: closed
  • Created 11 years ago
  • Comments: 17 (6 by maintainers)

Most upvoted comments

Unlike #219, this issue is about testing for a fatal error - then continuing! AFAICS that can only be achieved by going out of process (as the earlier parts of the thread discussed). So I think we need to leave this open (or close in favour of a single issue on the matter).