0

我有父类:

BaseClass;

它的子类是SubClass

当我需要一个子类的模拟子类时,如何命名它?

我检查了某人的代码示例,子类的模拟类和本身使用相同的名称,但是在不同的.h文件中,一个是subclass.h。另一个是mocksubclass.h,

所以在这种情况下,是否需要命名模拟子类以使用不同的名称,例如:MockSubClass

谢谢。

4

1 回答 1

0

Depends on your needs. The approach you mention is reasonable, i.e. CMyClass->CMockMyClass. Generally you will have a mock class per subclass, and there are times when you need to mock the base class as well. Using 'interface' classes can help when creating the mock classes, as per SO What mocking framework are you using? Are they true mocks or just stubs?

于 2013-05-13T01:55:20.853 回答