#27 Multi-instance test cases

open
nobody
5
2003-06-20
2003-06-20
No

If anyone is interested, I have a class for running
multiple instances of a test case. I attach a brief
explanation about the motivation and implementation of
the class. I would be useful, though, to add or change
the helper macros so that it will be possible to obtain a
factory function for a single case (that is, a single
member function) of a CppUnit::TestCase.

I send copies of this message to the Feature Requests
tracker and to the discussion forum. Please make
contact if you're interested in more details.

/*!
\brief Create and run multiple instances of the same
test case.

Class tstMultiInstanceTest extends the CppUnit::Test
class by adding
the option to create and run multiple instances of the
same test case.
This feature is useful, for example, when we want to
add randomization
to our test fixture. Consider the case of a test fixture
that creates
randomly-parametrized objects on instantiation, and
then tests these
objects using random input, which is determined at the
setUp() phase.
We want to repeat the ranodmized test a large number
of times, and for
a large set of random instances. But currently,
CppUnit::RepeatedTest
only enables to test a single instance multiple times,
and does not
consider multiple instances. Our class is made to
handle this case.

A tstMultiInstanceTest is initialized with a factory
function which
creates CppUnit::Test objects, and returns their
address. We can
change the number of instances at any time using the
SetNumInstances()
method. The instances are stored in a std::vector,
and SetNumInstances()
adds new test-case instances to the back of the
vector, or removes them
from there if we want to reduce the number of
instances.
*/

Discussion


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks