For example I have following test case:
#include <MyClass.hpp>
#define BOOST_TEST_MODULE MyTest
#include <boost/test/unit_test.hpp>
BOOST_AUTO_TEST_CASE( my_test )
{
MyClass o1(42), o2(21);
BOOST_CHECK( o1.is_valid() );
BOOST_CHECK_EQUAL( o1 == o2 * 2 );
BOOST_CHECK_EQUAL ...
...
}
There are several similar classes that are inheriting from same base class, would like to test them by the same logic, test cases might be like following:
BOOST_AUTO_TEST_CASE( my_test1 )
{
MyClass1 o1(42), o2(21);
BOOST_CHECK( o1.is_valid() );
BOOST_CHECK_EQUAL( o1 == o2 * 2 );
BOOST_CHECK_EQUAL ...
...
}
BOOST_AUTO_TEST_CASE( my_test2 )
{
MyClass2 o1(42), o2(21);
BOOST_CHECK( o1.is_valid() );
BOOST_CHECK_EQUAL( o1 == o2 * 2 );
BOOST_CHECK_EQUAL ...
...
}
BOOST_AUTO_TEST_CASE( my_test3 )
{
MyClass3 o1(42), o2(21);
BOOST_CHECK( o1.is_valid() );
BOOST_CHECK_EQUAL( o1 == o2 * 2 );
BOOST_CHECK_EQUAL ...
...
}
...
Is there a way to reuse logic in the test case?
Aucun commentaire:
Enregistrer un commentaire