您如何选择要运行的特定Google Mock测试用例/单元测试?

伦纳特

我有多个单元测试,每个类在单独的文件中。

我的标准单元测试之一如下所示:

#include "gmock/gmock.h"
#include "gtest/gtest.h"

class ClassAUnitTest : public ::testing::Test {
protected:
    // Per-test-case set-up.
    // Called before the first test in this test case.
    // Can be omitted if not needed.
    static void SetUpTestCase() {
        //..
    }

    // Per-test-case tear-down.
    // Called after the last test in this test case.
    // Can be omitted if not needed.
    static void TearDownTestCase() {
        //..
    }

    // You can define per-test set-up and tear-down logic as usual.
    virtual void SetUp() {  }
    virtual void TearDown() {
}
    // Some expensive resource shared by all tests.
    //..
};

TEST_F(ClassAUnitTest, testCase1) {
    // Assign .. Act .. Assert.
}

我知道的方法是将DISABLED_放在测试用例的前面,如下所示:

TEST_F(ClassAUnitTest, DISABLED_testCase1) {
    // Assign .. Act .. Assert.
}

但是,在一项失败的单元测试中运行所有测试非常不切实际。

我将Visual Studio Ultimate 2013与Gmock 1.7.0一起使用。

问题:如何轻松选择要运行哪些单元测试或特定测试,哪些不运行?

БJовић

首先,您的单元测试应该快如闪电。否则,人们将不会执行它们。

选择测试中所述,您可以--gtest_filter=选择使用选项。在您的特定情况下:--gtest_filter=ClassAUnitTest.*

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

无法运行单元测试用例

如何按照声明的顺序运行单元测试用例

在未运行测试用例的函数中创建单元测试用例类

如何为BadRequest编写单元测试用例?

如何同步执行Mocah单元测试用例?

如何为方法编写单元测试用例[Angular]

如何为Perl脚本编写单元测试用例

如何为Android API编写单元测试用例?

如何为Ansible功能创建单元测试用例?

业力测试用例正在运行多次:角度单元测试

在Visual Studio中运行单元测试时出错:缺少测试用例对象

在Python单元测试TestLoader中指定特定的测试用例

Catch.hpp单元测试:如何动态创建测试用例?

如何为测试用例生成一些报告以进行单元测试?

如何使用MTM将参数值从TFS中的测试用例传递到单元测试方法中的测试方法?

从单元测试用例运行线程是否是一种好习惯?

覆盖JS中特定单元测试用例的sinon存根

如何编写单元测试用例以为ListenableFuture添加回调

如何在单元测试用例中使用角度2中的文本查找右键

如何在javascript的单元测试用例中覆盖setInterval

Spring Boot:如何编写用于删除其余模板的单元测试用例

如何使用 flake8 作为单元测试用例?

如何编写单元测试用例以在 Angular 中使用下拉框列表提交表单?

如何使用Mockito为控制器类编写单元测试用例

如何在单元测试用例(grails,junit)中声明“ render”中的值

如何在UIWebView / WebKit中编写单元测试用例(XCTest)-Swift

如何在 Angular 中为 HTTPClient get() 方法服务编写单元测试用例?

如何在VS 2017 .net核心项目中生成单元测试用例?

如何为ExecuteNonQuery和ExecuteScalar和GetDataSet方法编写模拟单元测试用例