Does the feature exist in the most recent commit?
No, it does not
Why do we need this feature?
Global environment errors are displayed on the console, but parsing reports generated by --gtest_output is much more reliable.
Describe the proposal.
Consider the following test:
#include <gtest/gtest.h>
class PSEnvironment : public ::testing::Environment
{
private:
void SetUp() override {
GTEST_FAIL() << "PSEnvironment::SetUp fail" << std::endl;
}
};
const auto g_env = ::testing::AddGlobalTestEnvironment(new PSEnvironment());
TEST(MyTest, MyTestCase) {
// ...
}
Its console output is as follows:
[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
test.cpp(7): error: Failed
PSEnvironment::SetUp fail
[ RUN ] MyTest.MyTestCase
test.cpp(13): error: Due to preparation errors, the test is explicitly marked as failed and will not be run.
[ FAILED ] MyTest.MyTestCase (0 ms)
[----------] Global test environment tear-down
[==========] 1 test from 1 test suite ran. (4 ms total)
[ PASSED ] 0 tests.
[ FAILED ] 1 test, listed below:
[ FAILED ] MyTest.MyTestCase
1 FAILED TEST
As expected, error from PSEnvironment::SetUp is displayed.
However, that error is nowhere to be found in reports generated by --gtest_output=xml:<path>:
<?xml version="1.0" encoding="UTF-8"?>
<testsuites tests="1" failures="1" disabled="0" errors="0" time="0.003" timestamp="2026-01-26T08:28:29" name="AllTests">
<testsuite name="MyTest" tests="1" failures="1" disabled="0" errors="0" time="0" timestamp="1970-01-01T00:00:00">
<testcase name="MyTestCase" status="run" result="completed" time="0" timestamp="1970-01-01T00:00:00" classname="MyTest">
<failure message="test.cpp:13
Due to preparation errors, the test is explicitly marked as failed and will not be run." type=""><![CDATA[test.cpp:13
Due to preparation errors, the test is explicitly marked as failed and will not be run.]]></failure>
</testcase>
</testsuite>
</testsuites>
The same with --gtest_output=json.
Please add errors generated by global environment setup to the reports generated by --gtest_output. If backward compatibility is a concern, it may be implemented in a new report type, like --gtest_output=xml_v2.
Is the feature specific to an operating system, compiler, or build system version?
Not specific no any OS, compiler or build system
Does the feature exist in the most recent commit?
No, it does not
Why do we need this feature?
Global environment errors are displayed on the console, but parsing reports generated by --gtest_output is much more reliable.
Describe the proposal.
Consider the following test:
Its console output is as follows:
As expected, error from
PSEnvironment::SetUpis displayed.However, that error is nowhere to be found in reports generated by
--gtest_output=xml:<path>:The same with
--gtest_output=json.Please add errors generated by global environment setup to the reports generated by
--gtest_output. If backward compatibility is a concern, it may be implemented in a new report type, like--gtest_output=xml_v2.Is the feature specific to an operating system, compiler, or build system version?
Not specific no any OS, compiler or build system