gpt4 book ai didi

c++ - 运行测试直到失败

转载 作者:太空宇宙 更新时间:2023-11-04 12:54:14 25 4
gpt4 key购买 nike

有没有办法在 Visual Studio 中运行谷歌测试直到它失败??

我有此 TEST_F(PersistentStorageTestFixture, test_PSF_U13) 测试失败,但它是间歇性的。我需要一次又一次地运行它直到它失败,有什么想法吗?

最佳答案

您可以在 google test 命令之后放置选项。要仅运行一些单元测试,您可以使用 --gtest_filter=Test_name* 命令行选项,其值为正则表达式。

然后您可以创建一个脚本来循环运行该程序,直到它返回不同于 0 的值。

// Use this macro in main() to run all tests.  It returns 0 if all
// tests are successful, or 1 otherwise.
//
// RUN_ALL_TESTS() should be invoked after the command line has been
// parsed by InitGoogleTest().

#define RUN_ALL_TESTS()\
(::testing::UnitTest::GetInstance()->Run())

关于c++ - 运行测试直到失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47388888/

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