当第一个测试失败时,如何停止GTest测试用例的执行 [英] How to stop GTest test-case execution, when first test failed

查看:278
本文介绍了当第一个测试失败时,如何停止GTest测试用例的执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一些 #define ,如果第一次测试失败,该代码可以停止测试用例的执行

I'm looking for some #define which can stop test-case execution if first test failed

TEST_F(TestInitializer, 1st-test) {
  Initiator.call();      
  EXPECT_CALL(mock_obj, onAction(false)).Times(AtLeast(0));

  // some define I want
  ::testing::stopIfFailed();
}

TEST_F(TestInitializer, 2nd-test) {
  // this test must not be executed if first test failed
}

推荐答案

运行带有--gtest_break_on_failure标志的二进制文件

run binary with flag --gtest_break_on_failure

这篇关于当第一个测试失败时,如何停止GTest测试用例的执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆