C++ : Is it possible to write Mock class for a class with parameterized constructor

标签 c++ mocking googletest googlemock

我正在使用 Google Mock 框架开发单元测试用例。 对于所有具有默认构造函数的类,我能够编写一个模拟类并模拟所需的方法。 但是我们是否可以为没有默认构造函数/有构造函数但有参数的类编写模拟类?

最佳答案

is it possible for us to write a mock class for a class with no default constructor/ with a constructor but with parameters?

绝对是!我已经写过这样的模拟类(class)。

您有什么特别的问题吗?然后请展示并让他们清楚。

关于C++ : Is it possible to write Mock class for a class with parameterized constructor,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17601468/

相关文章:

RSpec:方法内外部对象的 stub 方法调用

c++ - 如何将 Google Test 测试用例标记为 "expected to fail"?

C++ 2D int数组输出随机符号

c++ - 为 'FileCase' 错误指定的存储类

c++ - MFC PostMessage 从主项目到 UI 线程

c# - 是否有必要模拟单元测试中的所有依赖项?

c++ - 使用 delphi 调用 dll - pcshll32.dll

java - 模拟对象来运行不同的 void 方法

c++ - googletest doc C 字符串和字符串

c++ - 如何使用 GTest 测试严重依赖 MFC 的方法