-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Open
Labels
Description
Does the feature exist in the most recent commit?
No.
The current GoogleTest API does not provide a supported way to automatically capture, aggregate, and programmatically inspect multiple failures within a single test scope. Existing helpers such as EXPECT_NONFATAL_FAILURE and EXPECT_FATAL_FAILURE are limited to validating only one expected failure.
Why do we need this feature?
GoogleTest allows multiple EXPECT_* assertions to fail within one test, but there is no automation-friendly way to:
- Capture all failures in a defined scope
- Validate multiple expected failures in one test
- Access structured failure metadata programmatically
This limitation makes it difficult to:
- Build higher-level testing frameworks on top of GoogleTest
- Perform meta-testing (testing tests)
- Validate error-reporting behavior
- Generate structured CI or tooling outputs
Describe the proposal.
Introduce an opt-in failure aggregation mechanism that:
- Captures all fatal and non-fatal failures within a scoped block
- Exposes structured failure data (message, type, file, line)
- Allows validating multiple failures in a single test
- Does not alter existing test behavior or outputs unless explicitly enabled
GTEST_CAPTURE_FAILURES({
EXPECT_EQ(a, b);
EXPECT_TRUE(x);
});
EXPECT_FAILURE_COUNT(2);
Is the feature specific to an operating system, compiler, or build system version?
No. The feature is:
- Platform-independent
- Compiler-agnostic
- Build-system neutral (works with CMake, Bazel, etc.)
It would rely only on GoogleTest’s internal failure reporting mechanisms and be implemented in a portable, cross-platform manner.