如何选择特定的Google Mock测试用例/单元测试来运行?
How can you select specific Google Mock test cases/unit tests to run?
我有多个单元测试,每个类在一个单独的文件中。
我的一个标准单元测试是这样的:
#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。
问题:如何方便地选择运行哪些单元测试或特定测试,哪些不运行?
首先,你的单元测试应该是闪电般的快。否则人们不会执行它们。
如选择测试中所述,您可以使用--gtest_filter=
选项。在您的具体情况下:--gtest_filter=ClassAUnitTest.*
相关文章:
- 如何使用重载的相等(==)运算符向测试用例添加描述
- 从父数组测试用例构造二叉树失败
- 在Raspbian上编译pybind11测试用例时出现致命错误
- 我遇到了黑客排名中的问题"TWO STRINGS"的三个测试用例的分段错误。原因是什么?
- 某些测试用例未通过
- 如何在多个 Catch2 测试用例中检查相同的条件
- 谷歌启动2018,测试用例中的整数错误
- 用于查找连续子数组的最大总和的代码使测试用例失败
- 查找不适用于 c++ 中特定测试用例的最长子字符串
- 测试用例状态为失败,但返回的值为 true
- kill syscommand 在 Catch2 测试用例中失败
- 大型测试用例中C++ dfs 问题中的小错误
- 为什么在输入的第一行输入测试用例数量后得到垃圾值?
- C++ Catch 是否有类似 NUnit 的测试用例的东西,具有多个参数/输入选项
- 如何修复此代码对几个测试用例的错误答案?
- 所有测试用例都将小数点转换为二进制数
- C++回文检查解决方案被一个测试用例跳闸
- 测试用例大小为 10 的向量失败
- 将 argc 和 argv 传递给 QApplication 到单元测试用例方法中
- 如何选择特定的Google Mock测试用例/单元测试来运行?