在派生类上应用超类测试
假设您有一个从类 A
派生的 C++ 类 B
。您为类 A
设置了广泛的测试,您还希望在类 B
的实例上运行,因为它应该完全支持 A
'的功能。当然,您还可以进行额外的 B
特定测试。
您将如何设置测试,以便不必为 B
重复所有 A
的测试?
Google 测试的具体答案会很好。
Say you have a C++ class B
derived of class A
. You have extensive tests set up for class A
that you would also like to run over instances of class B
, as it should fully support A
's functionality. Of course you also have additional B
specific tests.
How would you setup the tests so that you don't have to duplicate all of A
's tests for B
?
A specific answer for Google Test would be great.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用类型化测试(如果您事先知道要测试哪些类型) )或类型参数化测试(如果您想解耦夹具从测试逻辑创建)。
Use Typed Tests (if you know in advance which types you want to test) or Type-Parameterized Tests (if you want to decouple fixture creation from test logic).