gpt4 book ai didi

c++ - 如何使用 Google Test 隐藏行号

转载 作者:行者123 更新时间:2023-11-28 05:05:18 25 4
gpt4 key购买 nike

如果测试失败,我试图在控制台 GTest 输出中隐藏行号。

例如:

/Projects/Dya/tests/main.cpp:22: Failure
Expected: object->calc(expr, params)
Which is: "5" To be equal to: "2"

我想隐藏这个:

/Projects/Dya/tests/main.cpp:22:

这可能吗?

感谢您的回答。

最佳答案

我很确定你不能。我看到一个用于隐藏耗时和关闭彩色输出的选项,但没有用于文件名的选项。

如果您使用 -h 标志运行您的测试程序,它将显示支持的选项列表。这是我得到的:

This program contains tests written using Google Test. You can use the
following command line flags to control its behavior:

Test Selection:
--gtest_list_tests
List the names of all tests instead of running them. The name of
TEST(Foo, Bar) is "Foo.Bar".
--gtest_filter=POSTIVE_PATTERNS[-NEGATIVE_PATTERNS]
Run only the tests whose name matches one of the positive patterns but
none of the negative patterns. '?' matches any single character; '*'
matches any substring; ':' separates two patterns.
--gtest_also_run_disabled_tests
Run all disabled tests too.

Test Execution:
--gtest_repeat=[COUNT]
Run the tests repeatedly; use a negative count to repeat forever.
--gtest_shuffle
Randomize tests' orders on every iteration.
--gtest_random_seed=[NUMBER]
Random number seed to use for shuffling test orders (between 1 and
99999, or 0 to use a seed based on the current time).

Test Output:
--gtest_color=(yes|no|auto)
Enable/disable colored output. The default is auto.
--gtest_print_time=0
Don't print the elapsed time of each test.
--gtest_output=xml[:DIRECTORY_PATH/|:FILE_PATH]
Generate an XML report in the given directory or with the given file
name. FILE_PATH defaults to test_details.xml.

Assertion Behavior:
--gtest_death_test_style=(fast|threadsafe)
Set the default death test style.
--gtest_break_on_failure
Turn assertion failures into debugger break-points.
--gtest_throw_on_failure
Turn assertion failures into C++ exceptions.
--gtest_catch_exceptions=0
Do not report exceptions as test failures. Instead, allow them
to crash the program or throw a pop-up (on Windows).

Except for --gtest_list_tests, you can alternatively set the corresponding
environment variable of a flag (all letters in upper-case). For example, to
disable colored text output, you can either specify --gtest_color=no or set
the GTEST_COLOR environment variable to no.

For more information, please read the Google Test documentation at
https://github.com/google/googletest/. If you find a bug in Google Test
(not one in your own code or tests), please report it to
<googletestframework@googlegroups.com>.

关于c++ - 如何使用 Google Test 隐藏行号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44969361/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com