On Sun, 21 Sep 2003, Dmitry Diskin wrote:
Hello All
I have to design unit tests for large OO application (yes, next time we will create tests before coding). But which is the best way to organize tests?
In the Test::Unit distribution I saw 't' directory with 'head' scripts (all_tests.t, assert.t) and 'tlib' directory with nested class directories.
That's the perl/CPAN test scripting used during the make;make test;make install
process used for installing perl modules. They aren't unit tests in the
strict sense, but could be written that way. I don't use them for
actual unit tests.
Test::Unit is based more on JUnit ideas and is easier to adapt to.
You can get a lot of basic test philosophy from the junit.org site: http://www.junit.org/index.htm
Here is another good site: http://www.xprogramming.com/
The downloads page there has links to several Perl test tools.
How you organize your tests depends a lot on what language you're using and if you intend to include the tests with the product, or exclude them. In Java, I'll create a top-level tests directory and duplicate the class tree there, ie:
tests/foo/bar tests/foo/baz src/foo/bar src/foo/baz
that way when I compile src, the tests aren't written to the classes path, and the tests are excluded from the final product.
If it's an opensource project, then I use: src/foo/bar src/foo/bar/tests src/foo/baz src/foo/baz/tests
and then classes gets the tests and so do the user/developers.
It all just depends on what you need to do with the test code and how the language works. There is no one right answer.
PS: I'm only online on the weekends, 'cause I got laid off last year and resorted to driving trucks for a living because I couldn't get a perl/java job in Minnesota.
I'm using perl unit these days, using a little front-end of my own and some customization of runonetest.pl to make it spit out html. I use mozilla as my GUI now. I haven't looked at RUI yet but it sounds interesting.
Thank you very much for your answer. I decided to create 'tests' directories under each class and subclass directory (the same way it is done in RUI project):
src/foo/ src/foo/tests src/foo/bar src/foo/bar/tests src/foo/baz src/foo/baz/tests
Each tests subdirectory contain AllTests.pm and, optionally, TestCase.pm (if a class does not have TestCase.pm, in uses one from it's parent class). Sample data for tests goes to 'data' subdirectory of corresponding 'tests' directory.
I have plans to subclass TestRunner class and create 'CGITestRunner'. The main idea is to be able to show tests as a tree, and to let user to check any combination of testSuites to be run, and to show results in HTML. If you can share your code here -- please do, it is interesting to look at it.
Thanks again, and good luck!
-- Dmitry.
------------------------------------------------------- This SF.net email is sponsored by: SF.net Giveback Program. SourceForge.net hosts over 70,000 Open Source Projects. See the people who have HELPED US provide better services: Click here: http://sourceforge.net/supporters.php _______________________________________________ Perlunit-users mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/perlunit-users
