【发布时间】:2013-09-02 18:37:45
【问题描述】:
我想知道用于测试基类的有效设计或实现。
举个例子:
class Polygon;
class Rectangle : public Polygon;
class Triangle : public Polygon;
其中Rectangle 和Triangle 继承自Polygon。
我想让Rectangle 和Triangle 的测试类使用基础测试类:
class Test_Rectangle : public CppUnit::TestFixture;
class Test_Triangle : public CppUnit::TestFixture;
但我不知道class Test_Polygon 是否应该从CppUnit::TestFixture 继承。
我目前的计划是: 类Test_Polygon; 类Test_Rectangle:公共Test_Polygon,公共CppUnit::TestFixture; 类 Test_Triangle : public Test_Polygon, public CppUnit::TestFixture;
上述计划的问题是Test_Polygon不能使用CPPUNIT_ASSERT,其方法也不会列在CPPUNIT注册表中。
那么,使用 CPPUNIT 测试基类和后代的推荐层次结构是什么?
(我在 Windows Vista 上使用 CPPUNIT 1.12 和 Visual Studio 2008。)
【问题讨论】:
标签: c++ unit-testing visual-studio-2008 cppunit