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

标签 c++ visual-studio testing googletest

有没有办法在 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/

相关文章:

typescript - 执行测试时,不调用该函数

c++ - unicode 正则表达式 C++

c++ - C++ 任务栏中的闪烁/警报

c# - otside 类放置在 Form 中的 Visual Studio 调用方法

visual-studio - Visual Studio 2012 无法识别 Xaml 文件,设计 View 已损坏

angularjs - 需要在 Protractor 测试用例中访问我的 angular.service

c++ - 隐式转换未按预期工作

C++ 转换运算符重载

visual-studio - 当我在代码编辑器中选择文本时 Visual Studio 崩溃

python - 带有 modelchoicefield 的 Django 测试表单