[FR]: Test names output by googletest are too long
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 39.6k
- Forks
- 10.9k
- Avg merge
- 6d 13h
- Merged PRs (30d)
- 1
Description
Does the feature exist in the most recent commit?
No.
Why do we need this feature?
I have a test suite called AutoTest with a parameterized test called Compile. The parameter is a custom type. I provide a function as the 4th argument to INSTANTIATE_TEST_SUITE_P that generates test names based on the parameter. When googletest lists tests names, it prints stuff like A/AutoTest.Compile/firstpass_preproc_set # GetParam() = 64-byte object <10-61 1E-61 40-7B 00-00 2F-00 00-00 00-00 00-00 2F-00 00-00 00-00 00-00 BE-BE BE-BE BE-BE BE-BE 40-82 23-61 40-7C 00-00 01-00 00-00 00-00 00-00 00-00 00-40 00-00 00-00 00-00 00-00 00-00 00-00>. Everything following the string that my function generates ("firstpass_preproc_set" in this case) is basically undesired spam. It's just noise that takes up precious screen real estate.
Describe the proposal.
I suppose the intent behind " # GetParam() = . . ." was to print the parameter as a way to clarify which value is being used as the parameter to a TEST_P, but I (like most parameterized test users, I'd think?) already use the 4th argument to INSTANTIATE_TEST_SUITE_P to provide all the information I need to know about the value. There is nothing more of value to be printed aside from the name I'm already giving it.
I found a documented way to provide a custom string formatter for my parameter type, which I can make return an empty string, but googletest still outputs the undesired " # GetParam() = ".
I modified googletest to stop it from doing this (in UnitTestImpl::ListTestsMatchingFilter) but would love to know if there is an official way to get test names listed without the "# GetParam()" stuff. If there is no official way, please add one.
Is the feature specific to an operating system, compiler, or build system version?
No.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at UnitTestImpl::ListTestsMatchingFilter, where the issue reports that the parameter text is appended to listed test names, and review the documented custom string formatter behavior. Determine how an official opt-out could fit the existing parameterized-test naming flow. Done means users can list tests using their generated names without the unwanted "# GetParam() =" suffix.
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
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100