[Cppunit-devel] TestContext
Brought to you by:
blep
|
From: Michel A. <Arm...@si...> - 2002-07-19 07:21:52
|
Hi again.
Maybe it would be worthwhile to introduce a TestContext class that is
responsible for encapsulating test data that is read in at runtime (see XML
parameterized tests topic).
This TestContext class should be retrievable from CppUnit::Test, enabling
TestListeners to make use of it too (e.g. Outputter subclass could report
about the actual set of parameters used for the execution of a test).
The problem is that I don't know what the interface of TestContext should
look like. It should be flexible enough to allow for an open set stored
information. A simple solution could allow for the following:
class TestContext {
std::istream& getStream(const std::string& name) = 0;
void setStream(std::istream& stream, std::string& name) = 0;
};
Alternatively, TestContext could contain a (fixed) set of HashMaps that are
specialized for a (fixed) set of types (std::string, std::istream, ...).
Each of these HashMaps would contain named objects of the corresponding
types. This approach would also allow to (type-safely) iterate through the
complete content of a TestContext object, a fact which is certainly useful
when talking in terms of test reports.
For example, a TestMethod/TestListener etc. could call getStream("in"),
getStream("exp"), getStream("description") etc. to retrieve and use the
corresponding (named) streams.
I don't believe that this is a very elaborated/good solution yet. But I hope
that it can at least serve as a basis for discussion.
Armin.
|