google / googletest

GoogleTest - Google Testing and Mocking Framework

Home Page:https://google.github.io/googletest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

With AllOf (and similar), output which of the individual matcher(s) succeeded/failed

sfc-gh-sgiesecke opened this issue · comments

Does the feature exist in the most recent commit?

No

Why do we need this feature?

When using a composite AllOf matcher, the current output gives no hint on which individual matcher failed in case any of those failed.

While in other cases, the assertion might be split up, this does not work with EXPECT_EXIT and the like.

However, it's probably also useful with EXPECT_THAT.

Describe the proposal

A use of AllOf like:

EXPECT_EXIT({ fputs("foo", stderr); _exit(3); }, ExitedWithCode(3), AllOf(HasSubstr("foo"), ContainsRegEx("bar.*42")));

should output something like:

Death test: { fputs("foo", stderr); _exit(3); }
    Result: died but not with expected error.
  Expected: (has substring "foo") [SUCCEEDED] and (contains regular expression "bar.*42") [FAILED]
Actual msg:
[  DEATH   ] foo

Note the additional [SUCCEEDED] and [FAILED] parts compared to the current output.

This is a very simple case with a short process output and simple individual matchers. However, in case of a process with a long output, combined with complex regular expressions, it may be very hard to understand what's going on without experimentally modifying the test code.

Is the feature specific to an operating system, compiler, or build system version?

No.