google / google/googletest

[Bug]: gtest_output xml copies failure message into both <failure> element body and attribute 'message'

Open
#4,785 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
39.5k
Forks
10.9k
Avg merge
6d 13h
Merged PRs (30d)
1

Description

### Describe the issue

Google test seems to fill the junit-style XML document produced with with the failure from ASSERT or EXPECT statements twice. This simply reduces the quality of the failure report.

I'm working with some very large matrices that get dumped on failure and I lost several minutes of time before realizing that my reporting system was showing me the same data twice.

### Steps to reproduce the problem

write a simple test to induce a failure

```cpp
TEST(test_suite, test_function)
{
EXPECT_EQ(1, 2) << "I figure 1 is close enough to 2 they should be the same";
}
```

run this test suite with `--gtest_output=xml`

expected test_detail.xml:

_note: what follows is a manually mangled version of an existing failing test I have_

```xml





```

(note: a very terse summary in testsuites/testsuite/testcase/failure[message])

actual:

```xml





```

note the duplication of the comparison failure and error message; it is repeated twice, once it is encoded for XML attribute string, the other time it is dumped in the body of an element as a CDATA block.

### What version of GoogleTest are you using?

1.14.0

pulled via cmake's FetchContent: https://github.com/google/googletest/archive/refs/tags/v1.14.0.zip

### What operating system and version are you using?

Ubuntu 24.04 (linux 6.6.8)

```
uname -a
Linux Batou 6.6.87.2-microsoft-standard-WSL2 #1 SMP PREEMPT_DYNAMIC Thu Jun 5 18:30:46 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux
groostav@Batou:~/Metamodelling/cmake-build-debug-ninja-vcpkg-wsl/bin$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 24.04.2 LTS
Release: 24.04
Codename: noble
```

### What compiler and version are you using?

gcc 13.3.0

```
gcc --version
gcc (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0
```

### What build system are you using?

cmake 3.28.3
ninja 1.11.1

### Additional context

I use junit all the time but i don't actually have the runner installed, if need be i can find out what junit does exactly but IIRC the `message` will just be the java exception's message and the failure body will be the exception printed with stack trace.

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue with the provided TEST(test_suite, test_function) example and --gtest_output=xml, then inspect the XML output generation path. The change is complete when the failure attribute contains only a terse summary while the failure element body retains the full comparison message, without duplicating the same text.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
testing-qa
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.