Catch2 icon indicating copy to clipboard operation
Catch2 copied to clipboard

Feature Request: Implementing custom failure message for REQUIRE/CHECK macros

Open ceztko opened this issue 2 years ago • 1 comments

Description

I suggest catch2 to implement a semantic to display some messages only in case of failures. GoogleTest has it in this form:

EXPECT_TRUE(false) << "Something went wrong";

CppUnit has it in this form:

CPPUNIT_ASSERT_MESSAGE(message, condition)

Boost has it in this form:

BOOST_ASSERT_MSG(expr, msg)

Microsoft unit testing framework for c++ has it in this form:

Assert::IsTrue(condition, message)

I'm not suggesting how to implement it but I believe a facility to implement the same semantics should exist in Catch2 as well. I understand the desire to keep the number of macros small and not have a hell of AssertTrue, AssertFalse, AssertEqual, etc. , but what I'm asking is something that can't be replaced by formulating the condition in a different way.

Additional context

This is the same request as in https://github.com/catchorg/Catch2/issues/929 , that was closed by its author when explained to use INFO instead. Other people in the issue (including me) intervened to ask for the same semantics because the use of INFO is not really a replacement.

ceztko avatar Mar 10 '23 09:03 ceztko

+1

arthuraraujo-msft avatar Jan 18 '24 15:01 arthuraraujo-msft