google / googletest

GoogleTest - Google Testing and Mocking Framework
https://google.github.io/googletest/
BSD 3-Clause "New" or "Revised" License
33.78k stars 10k forks source link

[Bug]: GTest Succeeds when No Tests Found #4360

Open celestialorb opened 10 months ago

celestialorb commented 10 months ago

Describe the issue

Recently we had a developer make a typo that resulted in no tests being picked up by googletest, but rather than reporting an error akin to "failed to find any tests", the run succeeded.

I looked through the documentation for googletest but couldn't find any kind of flag to force it to fail when no tests are run. Did I miss something, or does the ability to control the behavior of googletest in this scenario not exist?

Steps to reproduce the problem

Create a simple project with a source file that doesn't contain any tests and run googletest over it.

What version of GoogleTest are you using?

Literally no idea, as googletest is vendored into the monorepo at this organization and there's no version information I can find that's associated with it.

What operating system and version are you using?

Ubuntu 14.04 LTS.

What compiler and version are you using?

gcc version 4.8.5 (Ubuntu 4.8.5-4ubuntu8~14.04.2)

What build system are you using?

bazel 4.2.2-2.6

Additional context

No response

derekmauro commented 9 months ago

It seems like a potentially desirable change to add a flag to make this happen. If we were designing this from scratch it might be the default, but I think today there are tests that intentionally do nothing, for example, because they are intentionally compiled out on platforms that aren't supported.

https://github.com/google/googletest/pull/4192 might be a slightly better version of this feature though,

shekhar-chauhan commented 3 months ago

I'd be more than happy to take over the issue if someone can do a basic code walkthrough for me, regarding what all places do I need to look into and such.