Catch2
Catch2 copied to clipboard
Compact reporter does not handle [!shouldfail] properly
Description
Compact reporter does not handle the [!shouldfail]
tag properly. Given this code (from #876):
bool thisThrows() {
throw std::runtime_error("Boom");
}
TEST_CASE("#748 - captures with unexpected exceptions", "[!shouldfail]") {
int answer = 42;
CAPTURE(answer);
// the message should be printed on the first two sections but not on the third
SECTION("outside assertions") {
thisThrows();
}
SECTION("inside REQUIRE_NOTHROW") {
REQUIRE_NOTHROW(thisThrows());
}
SECTION("inside REQUIRE_THROWS") {
REQUIRE_THROWS(thisThrows());
}
}
compact reporter's output is
<snip>
Passed all 0 test cases with 1 assertion.
which, while kind-of correct, is surprising. Standard console reporter's output looks like this:
<snip>
test cases: 1 | 1 failed as expected
assertions: 3 | 1 passed | 2 failed as expected
which is much clearer about what happened and should be in some way replicated by the compact reporter.
Extra information
- Catch version: v1.8.2
I thought a bit about how this might look like but any attempts to have all the information on a single line ended up being quite messy (and it will only get worse with #2360). How about we just copy the output format from the console reporter exactly, save for the "totals divider"?
Yeah, that seems fine.
Okay, stylistically, would you prefer (1) a common base class for console and compact reporter, (2) free functions used by both or (3) code duplication?
- or 3), depending on how annoying the signature would be. I don't think the console and compact reporters should have a shared base class.