----- Original Message -----
From: "Loh, Choo Woon" <Cho...@au...>
To: "'Baptiste Lepilleur '" <gai...@fr...>
Sent: Tuesday, June 04, 2002 1:51 PM
Subject: RE: [Cppunit-devel] CPPUnit Cookbook Bug
> Hi there Baptiste,
> Thanks for the quick response. For the bug, instead of
> passing in the class itself as shown in the cookbook, it should have
passed
> in the test suite.
>
> Regarding the suggestion, it was not clear that I still had to add the
test
> methods to the suite (using CPPUNIT_TEST() macro) after calling
> CPPUNIT_TEST_SUITE(). My example was actually incorrect. What I meant to
> suggest was :-
>
> CPPUNIT_TEST_SUITE( ComplexNumberTest );
> CPPUNIT_TEST( testEquality );
> CPPUNIT_TEST( testAddition );
> CPPUNIT_TEST_SUITE_END();
This declare the test suite (behind the scene, it implements a static
suite() method and add it test to the suite that is returned). At that
point, the static suite() method is never called.
> This works. However, I tried the following :-
>
> CPPUNIT_TEST_SUITE_REGISTRATION( ComplexNumberTest );
Check this 'define' documentation. It should only be used in the C++ file.
It instantiates a static object, which uppon construction will add the suite
returned by the static method suite() of the specified fixture to the test
registry (more precisely, it will add a factory to instiate that suite).
Baptiste.
> CPPUNIT_TEST( testEquality );
> CPPUNIT_TEST( testAddition );
> CPPUNIT_TEST_SUITE_END();
>
> which does not work. Did I do something wrong here ?
> Thanks for any help.
>
> -----Original Message-----
> From: Baptiste Lepilleur
> To: Loh, Choo Woon; cpp...@li...
> Sent: 1/06/02 21:21
> Subject: Re: [Cppunit-devel] CPPUnit Cookbook Bug
>
> ----- Original Message -----
> From: "Loh, Choo Woon" <Cho...@au...>
> To: <cpp...@li...>
> Sent: Thursday, May 30, 2002 7:15 AM
> Subject: [Cppunit-devel] CPPUnit Cookbook Bug
>
>
> > In the line,
> >
> > #include <cppunit/extensions/HelperMacros.h >
> > CPPUNIT_TEST_SUITE_REGISTRATION( ComplexNumber );
> >
> > Behind the scene, a static variable type of AutoRegisterSuite is
> declared.
> > On construction, it will register a TestSuiteFactory into the
> > TestFactoryRegistry. The TestSuiteFactory returns the TestSuite
> returned
> by
> > ComplexNumber::suite().
> >
> > should be corrected as (highlighted in bold) :-
> >
> > #include <cppunit/extensions/HelperMacros.h >
> > CPPUNIT_TEST_SUITE_REGISTRATION( ComplexNumberTest );
> >
> > Behind the scene, a static variable type of AutoRegisterSuite is
> declared.
> > On construction, it will register a TestSuiteFactory into the
> > TestFactoryRegistry. The TestSuiteFactory returns the TestSuite
> returned
> by
> > ComplexNumberTest::suite().
> Fixed.
>
> > As a suggestion, you could improve the final example to use the other
> helper
> > macros as well :-
> >
> > CPPUNIT_TEST_SUITE_REGISTRATION( ComplexNumberTest );
> > CPPUNIT_TEST_SUITE( ComplexNumberTest );
> > CPPUNIT_TEST( testEquality );
> > CPPUNIT_TEST( testAddition );
> > CPPUNIT_TEST_SUITE_END();
> Could you explain in more details ?
>
> Baptiste.
> ---
> Baptiste Lepilleur <gai...@fr...>
> http://gaiacrtn.free.fr/
>
>
|