[Cppunit-devel] Bug or misunderstanding?
Brought to you by:
blep
|
From: <Seb...@en...> - 2002-12-19 22:46:02
|
Hi,
I'm just starting on a new project and we are going to use CppUnit as a
framework for our tests. Right now I'm working on the UI part of the
application and so I started out with creating a Fixture that contains a
UserInterface object as a member and has a static suite() function just as
described in the CookBook. The suite creates two (for now) TestCallers and
pass in test methods of the fixture. I expected one Fixture (and therefor
one UserInterface) to be created and that all the testmethods are called on
this one object (framed by calles to setUp() and tearDown() which reset the
UI object to a
known state.)
However, it turned out that for each TestCaller instantiated one Fixture
was instantiated and the testmethods were each called on a different
Fixture object. This resulted in multiple UI objects to be created and
since they create threads each calling a display driver which only expects
calls from one UI at a time ..... I think you can imagine ...
My understanding came from the following text from the CookBook:
"Ordinarily, you'll have many little test cases that you'll want to run on
the same set of objects. To do this use a fixture. [...] A fixture is
a known set of objects that serves as a base for a set of test cases."
Now my question is: Am I doing something wrong or is this a bug in CppUnit
or is this intended behaviour (in which case I think the docu should be
updated.)?
Also if this is intended, can you give me just a pointer on how to do this
kind of thing? Should I subclass TestSuite and keep the persistent objects
there?
Another, completely unrelated, issue is that I get a warning from the
following code:
#ifndef _test_sm70Test_h_
#define _test_sm70Test_h_
#include "cppunit/ui/text/TestRunner.h"
#include "pfl/thread.h"
namespace sm70
{
class RunCppUint : public pfl::Thread
{
CppUnit::TextUi::TestRunner runner;
void* run();
public:
RunCppUint();
};
}
#endif
The warning:
"/usr/local/include/cppunit/ui/text/TextTestRunner.h", line 88: Warning:
CppUnit::TextTestRunner::run hides the virtual function
CppUnit::TestRunner::run(CppUnit::TestResult&, const
std::basic_string<char, std::char_traits<char>, std::allocator<char>>&)
It does not keep me from compiling or running the tests (they seem to run
fine apart from above's problem) but it is rather anoying.
Thanks for your help,
Seb
|