Thread: [Cppunit-devel] news features...
Brought to you by:
blep
From: Baptiste L. <bl...@cl...> - 2001-10-02 20:42:39
|
1) CPPUNIT_TEST_EXCEPTION( method, ExceptionType) 2) CPPUNIT_TEST_FAIL( method ) 4) CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( TestFixtureType, SuiteName ) : register the fixture's suite in a suite of the specified name. Those features have been added. I would really appreciate if somebody could read and adjust the documentation of those macros. Somebody reviewing the TestFactoryRegistry code would be nice too (probably the weirdest life-cycle managment I've ever done). CppUnit test suite hierarchy have been reworked to use CPPUNIT_TEST_SUITE_NAMED_REGISTRATION (one of the problem of singleton is that they are very difficult to test. So CppUnit itself use the things that may break in the TestRegistry). You can found a screen-shot of the hiearchy there: http://gaiacrtn.free.fr/cppunit/CppUniTestHierarchy-20011002.jpg Now, there still one little piece of TestFactoryRegistry that need work. To create the suite hierarchy, we do (CppUnitTestSuite.cpp): CppUnit::TestFactoryRegistry ®istry = CppUnit::TestFactoryRegistry::getRegistry(); istry.registerFactory( &CppUnit::TestFactoryRegistry::getRegistry( coreSuiteName() ) ); registry.registerFactory( &CppUnit::TestFactoryRegistry::getRegistry( helperSuiteName() ) ); ... As you figured out, it would be nice to be able to do: registry.registerNamedRegistry( coreSuiteName() ); registry.registerNamedRegistry( helperSuiteName() ); What I need is a good name for the method. What this method does can be really confusing, so a good name would help. Here is what it does (well, wording it can be somewhat confusing too...): You have a TestFactoryRegistry that contains a list of TestFactory. Since a TestFactoryRegistry is a TestFactory, you can add a TestFactoryRegistry to another TestFactoryRegistry (what is done in the example). The method would retreive the registry of the specified name using TestFactory::getRegistry( name ), and regist er that factory to its list of factory (using registerFactory). I would also need a macro name. The macro would work in the spirit of CPPUNIT_TEST_SUITE_REGISTRATION: CPPUNIT_REGISTER_REGISTRY_SUITE_INTO( suiteToRegisterName, suiteName ) // with some decorating, it would do: stFactory::getRegistry( suiteName).registerNamedRegistry( suiteToRegisterNam e ) Any suggestions ? Baptiste. |
From: Baptiste L. <bl...@cl...> - 2001-10-03 21:16:20
|
3) add a flag to TestFailure distinguishing error/failure, retains only one collection to store results (see other mail). DONE ! Refactored much of TextTestResult on the way. It is now much easier to tune the output. Also some simplification were made: assertion failures and errors are in only one list (the kind of failure is indicated in parenthesis after the test name). ----- Original Message ----- From: "Baptiste Lepilleur" <bl...@cl...> To: "Cpp Unit Develpment Mailing List" <cpp...@li...> Sent: Tuesday, October 02, 2001 10:39 PM Subject: [Cppunit-devel] news features... > 1) CPPUNIT_TEST_EXCEPTION( method, ExceptionType) > 2) CPPUNIT_TEST_FAIL( method ) > 4) CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( TestFixtureType, SuiteName ) : > register the fixture's suite in a suite of the specified name. > > Those features have been added. I would really appreciate if somebody > could read and adjust the documentation of those macros. Somebody reviewing > the TestFactoryRegistry code would be nice too (probably the weirdest > life-cycle managment I've ever done). [...] --- Baptiste Lepilleur <gai...@fr...> http://gaiacrtn.free.fr/index.html Author of The Text Reformatter, a tool for fanfiction readers and writers. Language: English, French (Well, I'm French). |
From: Baptiste L. <bl...@cl...> - 2001-10-05 08:07:22
|
A basic XML output has been added (I haven't tested it against XML software yet, but the unit test say it's ok. So if I didn't mess up with the format it should be ok). Somebody on the Unix side should check that everything build correctly. 115 Unit tests should be running. Baptiste. ----- Original Message ----- From: "Baptiste Lepilleur" <bl...@cl...> To: "Cpp Unit Develpment Mailing List" <cpp...@li...> Sent: Wednesday, October 03, 2001 11:14 PM Subject: Re: [Cppunit-devel] news features... > 3) add a flag to TestFailure distinguishing error/failure, retains only > one collection to store results (see other mail). > > DONE ! Refactored much of TextTestResult on the way. It is now much > easier to tune the output. Also some simplification were made: assertion > failures and errors are in only one list (the kind of failure is indicated > in parenthesis after the test name). > > ----- Original Message ----- > From: "Baptiste Lepilleur" <bl...@cl...> > To: "Cpp Unit Develpment Mailing List" <cpp...@li...> > Sent: Tuesday, October 02, 2001 10:39 PM > Subject: [Cppunit-devel] news features... > > > > 1) CPPUNIT_TEST_EXCEPTION( method, ExceptionType) > > 2) CPPUNIT_TEST_FAIL( method ) > > 4) CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( TestFixtureType, SuiteName ) > : > > register the fixture's suite in a suite of the specified name. > > > > Those features have been added. I would really appreciate if somebody > > could read and adjust the documentation of those macros. Somebody > reviewing > > the TestFactoryRegistry code would be nice too (probably the weirdest > > life-cycle managment I've ever done). > [...] --- Baptiste Lepilleur <gai...@fr...> http://gaiacrtn.free.fr/index.html Author of The Text Reformatter, a tool for fanfiction readers and writers. Language: English, French (Well, I'm French). |
From: Volker B. <vbo...@te...> - 2001-10-05 14:01:34
Attachments:
diff
|
On Fri, 5 Oct 2001, Baptiste Lepilleur wrote: > A basic XML output has been added (I haven't tested it against XML softwa= re > yet, but the unit test say it's ok. So if I didn't mess up with the forma= t > it should be ok). great to hear there's progress on the output front. Some months ago (when i didn't knew the new CppUnit) i started to add some convenient features to the output but found it very difficult to change something. (And i ended in rewriting a lot of TextTestRunner, TestResult and the Decorateur completely...) I wanted the following features: - for every test method the name of the test was printed to STDOUT either "passed", "failed" or "error". - after execution of every single Test: print the name of the test method and the execution time for the test to STDERR. (That way we could mis-use the Unittests for performance checks) - after each suite print either "--- suite: failed ---" or "--- suite: success ---" goes to STDOUT. - a more detailed summary of the suite is printed to STDERR. That way it was easy to get both, a compact log e.g. for a daily build, and a verbose log (first on STDOUT, the latter on STDERR). Additionally every failure and error is printed in the same format that is used by g++. When i run the compile like that make && ./MyClassTest from my IDE (emacs) I can use the editor's parser to get to the=20 location of test-errors using 'next-error'. And - an essential for batch processing - the TextTestRunner returned an exit code that was translated in an exit code of the program signaling error or success. I hope it will be easier to implement such a thing after your changes. > Somebody on the Unix side should check that everything build correctly. 1= 15 > Unit tests should be running. There is a problem with missing itoa() (not only) on Linux, gcc version 2.95.2. I have attached a fix. Regards, Volker --=20 Volker Boerchers <vbo...@te...> System Engineer TECON Systems AG, Perlengraben 2, 50676 K=F6ln, http://www.tecon.de Tel: +49-221-92007-55, Fax: +49-221-92007-77 |
From: Steve M. R. <ste...@vi...> - 2001-10-05 14:16:12
|
On Fri, Oct 05, 2001 at 04:01:13PM +0200, Volker Boerchers wrote: > Additionally every failure and error is printed in the same format that is > used by g++. When i run the compile like that > > make && ./MyClassTest > > from my IDE (emacs) I can use the editor's parser to get to the > location of test-errors using 'next-error'. Yes!! This is *very* convenient, and I ended up doing the same thing locally. :-) I really want to re-work the test-running code. I posted some initial thoughts back in June or July. I'm planning to re-work some of them into a proposal in the near future. -Steve -- by Rocket to the Moon, by Airplane to the Rocket, by Taxi to the Airport, by Frontdoor to the Taxi, by throwing back the blanket and laying down the legs ... - They Might Be Giants |
From: Baptiste L. <gai...@fr...> - 2001-10-05 15:27:01
|
Quoting Volker Boerchers <vbo...@te...>: > On Fri, 5 Oct 2001, Baptiste Lepilleur wrote: > [...] > I wanted the following features: > - for every test method the name of the test was printed to STDOUT > either "passed", "failed" or "error". > - after execution of every single Test: print the name of the test > method and the execution time for the test to STDERR. > (That way we could mis-use the Unittests for performance checks) > - after each suite print either "--- suite: failed ---" or > "--- suite: success ---" goes to STDOUT. > - a more detailed summary of the suite is printed to STDERR. Easier, but not everything can be done. Some stuff I have in my head is to split in two: - a TextTestListener which report progress with the dot. - a TextTestResultOutputter which output the test result (list failure details). In your case, you might as well go ahead and write your one VerboseTextTestListener which output test name and status. You can compute the test execution time by intercepting startTest() and endTest() in the TestListener. For suite status report, not much help. There still isn't anything called when a suite is started/finished. Might be added in the future, though it would probably be a different Listener (TestSuiteListener ?). For the detailed log, you subclassing TextTestResultOutputter to get what you want. > That way it was easy to get both, a compact log e.g. for a daily > build, > and a verbose log (first on STDOUT, the latter on STDERR). > > Additionally every failure and error is printed in the same format that > is > used by g++. When i run the compile like that > > make && ./MyClassTest > > from my IDE (emacs) I can use the editor's parser to get to the > location of test-errors using 'next-error'. Now, there is a funny thing. No later than this morning, I was thinking that I could add a "post build step" that would do myapp -selftest, and exits after running the test and reporting the error in VC++ format (slighty different from g++). The format I had in my head was (sketch): file (line) : test name (failure type) (multiline-)message Statistics That would be another Outputter (CompilerTestResultOutputter (base class), GccTestResultOutputter and MsvcTestResultOutputter ?) > And - an essential for batch processing - the TextTestRunner returned > an > exit code that was translated in an exit code of the program signaling > error or success. How about wasSucess() ? > I hope it will be easier to implement such a thing after your changes. Easier, but there still works to be done. The heavy refactoring done on TextTestResult makes it easier to customize a particular part, but further refactoring it still needed to reach Nirvana. > > Somebody on the Unix side should check that everything build > correctly. 115 > > Unit tests should be running. Are all the 115 unit tests running (e.g. did I forgot to add a file in the MakeFile ?) > > There is a problem with missing itoa() (not only) on Linux, gcc > version > 2.95.2. I have attached a fix. Thanks, I'll include that this evening. The baka I am completly forgot to check if itoa was ANSI (aren't an ANSI equivalent anyway ?) Baptiste. > > Regards, > Volker > -- > Volker Boerchers <vbo...@te...> > System Engineer > TECON Systems AG, Perlengraben 2, 50676 Köln, http://www.tecon.de > Tel: +49-221-92007-55, Fax: +49-221-92007-77 > --- Baptiste Lepilleur <gai...@fr...> http://gaiacrtn.free.fr/index.html Language: English, French |
From: Duane M. <dua...@ma...> - 2001-10-05 16:15:16
|
--- At Fri, 5 Oct 2001 17:26:56 +0200, Baptiste Lepilleur wrote: >> >> There is a problem with missing itoa() (not only) on Linux, gcc >> version >> 2.95.2. I have attached a fix. > > Thanks, I'll include that this evening. The baka I am completly forgot to >check if itoa was ANSI (aren't an ANSI equivalent anyway ?) itoa() is most certainly not ANSI and there is no ANSI equivalent. >- return ::itoa( value, buffer, 10 ); >+ ::sprintf( buffer, "%d", value ); While this replacement is ANSI, its not really in keeping with the rest of the code style. The rest of the code is largely C++ standard library. Therefore the replacement should be something like the toString() function in assertionTraits<>. Maybe that function should be brought out entirely and converted to a toString template function instead: template <T> std::string toString( const T& x ) { OStringStream ost; ost << x; return ost.str(); } ..Duane |
From: Baptiste L. <gai...@fr...> - 2001-10-05 17:02:40
|
Quoting Duane Murphy <dua...@ma...>: > --- At Fri, 5 Oct 2001 17:26:56 +0200, Baptiste Lepilleur wrote: > > >> > >> There is a problem with missing itoa() (not only) on Linux, gcc > >> version > >> 2.95.2. I have attached a fix. > > > > Thanks, I'll include that this evening. The baka I am completly > forgot to > >check if itoa was ANSI (aren't an ANSI equivalent anyway ?) (the question was 'aren't there'...) > > itoa() is most certainly not ANSI and there is no ANSI equivalent. Yup, was specific VC++ (at least that what the doc said when looked afterward). > > >- return ::itoa( value, buffer, 10 ); > >+ ::sprintf( buffer, "%d", value ); > > While this replacement is ANSI, its not really in keeping with the > rest > of the code style. The rest of the code is largely C++ standard > library. > Therefore the replacement should be something like the toString() > function in assertionTraits<>. Yes. I asked for an equivalent because OStringStream is the "heavy" canon. > Maybe that function should be brought out entirely and converted to a > toString template function instead: > > template <T> > std::string toString( const T& x ) > { > OStringStream ost; > ost << x; > return ost.str(); > } That would solve the local code duplication. Though I'm not sure if it is the right solution. I'm still playing the idea, but I'm considering introducing a CppUnit::String class. It would have helper for those comon conversion and supports both Unicode and ANSI in its interface (but would store everything as Unicode). This would make CppUnit full Unicode (at least for failure message). But the idea is still unclear about the interface of that string class... Baptiste. --- Baptiste Lepilleur <gai...@fr...> http://gaiacrtn.free.fr/index.html Language: English, French |