mirror of
https://github.com/google/googletest.git
synced 2025-11-30 08:07:27 -05:00
googletest: Add a flag to fail if no tests were selected to run.
There are two cases that prompt this behavior: - All test cases in the binary are disabled. - There are more shards defined than test cases, so some shards are empty. The result in each case is the same: the test runner needs to spin up additional processes that do nothing, which is wasteful, especially when tests need expensive resources. PiperOrigin-RevId: 769176856 Change-Id: Ifa399a0b7b68e4add5a94ca148b32b2938a8666d
This commit is contained in:
committed by
Copybara-Service
parent
7e2c425db2
commit
28e9d1f267
@@ -1940,6 +1940,21 @@ test case is linked in.
|
||||
Note that *any* test case linked in makes the program valid for the purpose of
|
||||
this check. In particular, even a disabled test case suffices.
|
||||
|
||||
### Enforcing Running At Least One Test Case
|
||||
|
||||
In addition to enforcing that tests are defined in the binary with
|
||||
`--gtest_fail_if_no_test_linked`, it is also possible to enforce that a test
|
||||
case was actually executed to ensure that resources are not consumed by tests
|
||||
that do nothing.
|
||||
|
||||
To catch such optimization opportunities, run the test program with the
|
||||
`--gtest_fail_if_no_test_selected` flag or set the
|
||||
`GTEST_FAIL_IF_NO_TEST_SELECTED` environment variable to a value other than `0`.
|
||||
|
||||
A test is considered selected if it begins to run, even if it is later skipped
|
||||
via `GTEST_SKIP`. Thus, `DISABLED` tests do not count as selected and neither do
|
||||
tests that are not matched by `--gtest_filter`.
|
||||
|
||||
### Repeating the Tests
|
||||
|
||||
Once in a while you'll run into a test whose result is hit-or-miss. Perhaps it
|
||||
|
||||
Reference in New Issue
Block a user