I am having trouble working around a problem with inheriting unit
test cases.
Suppose I have a base class Foo and several derived classes. Suppose
I have a corresponding base test case and I would like to reuse that
base test case with test cases for the derived classes.
What I would like to do is this, in highly stylized form:
class BaseFooTestCase {
public:
virtual Foo* create() = 0;
void test_base() {
Foo* foo = create();
// test foo ...
}
void add(test_suite* ts) {
ts->add(BOOST_CLASS_TEST_CASE(&BaseFooTestCase::test_base, this);
}
};
class DerivedFooTestCase {
public:
virtual Foo* create() { return new Derived(); }
void test_derived() {
Foo* foo = create();
// test foo
}
void add(test_suite* ts) {
BaseFooTestCase::add(ts);
ts->add(BOOST_CLASS_TEST_CASE(&DerivedFooTestCase::test_derived, this);
}
};
Then, something like this:
test_suite* init_unit_test_suite(int, char* []) {
auto_ptr
On Friday, January 28, 2005 at 16:23:57 (-0600) Bill Lear writes:
I am having trouble working around a problem with inheriting unit test cases. ...
I have found an answer:
#include <iostream>
#include
participants (1)
-
Bill Lear