Catch2 icon indicating copy to clipboard operation
Catch2 copied to clipboard

Compact reporter does not handle [!shouldfail] properly

Open horenmar opened this issue 7 years ago • 4 comments

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

horenmar avatar Apr 03 '17 12:04 horenmar

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"?

psalz avatar Oct 17 '22 12:10 psalz

Yeah, that seems fine.

horenmar avatar Oct 17 '22 15:10 horenmar

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?

psalz avatar Oct 18 '22 17:10 psalz

  1. 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.

horenmar avatar Oct 18 '22 21:10 horenmar