[FR]: `EXPECT_NONFATAL_FAILURE` and friends: Support multiple (variadic) substrings
- Dominant language
- C++
- Stars
- 39.5k
- Forks
- 10.9k
- Avg merge
- 6d 13h
- Merged PRs (30d)
- 1
Description
I would like to be able to pass multiple substrings to `EXPECT_NONFATAL_FAILURE` so that all the substrings must appear in the failure output.
This should I guess also apply to the other `EXPECT_(FATAL|NONFATAL)_FAILURE[_ON_ALL_THREADS]`.
### Does the feature exist in the most recent commit?
No
### Why do we need this feature?
When testing matchers that produce detailed output (e.g. multi-line, or printing details from inner/nested matchers), it's brittle and cumbersome to test either one big string (where the test now depends on unimportant indentation/formatting), or have to repeat the entire `EXPECT_NONFATAL_FAILURE` multiple times to verify multiple substrings.
### Describe the proposal.
For my use case, I want to be able to do something like:
```
EXPECT_NONFATAL_FAILURE(
[&] {
EXPECT_THAT(myObject, MyMatcher(...));
}(),
"Substring 1",
"Substring 2");
```
I haven't looked at whether this can be done in a backward compatible way using `__VA_ARGS__`/`__VA_OPT__`/etc.
### Is the feature specific to an operating system, compiler, or build system version?
No.
Contributor guide
Research direction
Start by locating the implementations of EXPECT_NONFATAL_FAILURE and the related EXPECT_(FATAL|NONFATAL)_FAILURE[_ON_ALL_THREADS] macros, then trace how their failure substrings are checked. Done means each macro accepts multiple substrings, requires every substring to appear, and preserves existing one-substring usage across the supported variants.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- testing-qa
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100