Hi all, The company I now work for uses testing modules developed here several years ago. One of my coworkers is curious to know how Perl's standard testing modules compare to the ones they use. He'll happily consider going with Perl's testing modules if there is a compelling reason to do so. I'm not particularly advocating one way or another, but I promised him I would shoot an email to the Perl QA list and ask for feedback. Frankly, I'm happy just to have testing here.
This is rather long and contains a fair number of samples, so I beg your patience. Thanks! Here's some sample code (stripped down for clarity): package RTK::Retail::Product::TEST::Supplier; use base qw/RTK::Retail::Meta::TestCase/; use RTK::Meta::Test::Asserts; use RTK::Retail::Product::TEST::Supplier::TestUtil; use Aliased 'RTK::Retail::Product::Supplier'; sub TEST_FIND_ALL { assert_lists_eq([Supplier->find_all], []); my $supplier1 = create_test_supplier( -supplier_no => 1, -name => 'Foo, Inc.' ); my $supplier2 = create_test_supplier( -supplier_no => 2, -name => 'Bar, Inc.' ); my @suppliers = sort map { $_->name } Supplier->find_all; my @actual_suppliers = ('Bar, Inc.', 'Foo, Inc.'); assert_lists_eq([EMAIL PROTECTED],[EMAIL PROTECTED]); my $supplier3 = create_test_supplier( -supplier_no => 3, -name => 'Baz, Inc.' ); @suppliers = sort map { $_->name } Supplier->find_all; @actual_suppliers = sort ('Baz, Inc.', 'Bar, Inc.', 'Foo, Inc.'); assert_lists_eq([EMAIL PROTECTED],[EMAIL PROTECTED]); } sub TEST_FIND_ALL_SORTED_BY_NAME { [snip] Each /^TEST__\w+/ subroutine is run and has a number of asserts in it. Each test subroutine is considered to be a test of a single type of functionality and if all asserts pass, the test is considered successful. Here's a sample of the output, running one test. TEST_FIND_ALL TEST_FIND_ALL --> Passed! Life is Wonderful! Running an entire test module (again, simplified for clarity): TEST_FIND_ALL .. Connecting to TEST database '[EMAIL PROTECTED]' passed (0.12s - 0.07 CPU) TEST_FIND_ALL_SORTED_BY_NAME ..passed (0.06s - 0.02 CPU) The "Connecting to TEST database .." line is important. There are three test databases are completely empty. At the beginning of a test program, the user is assigned on of the three databases (test fails if all are in use) and they are responsible for populating it with test data. Those are the 'create_test_supplier' lines in the code. At the end of each test function, the data is automatically removed from the database. Each function has setup and teardown functions that are automatically run behind the scenes. Running the entire test suite is simply a matter of using their rtk_test program which spiders through the entire directory structure and runs all tests that it finds in any module (allowing inline tests, if desired). And a sample failure: TEST_FIND_ALL .. Connecting to TEST database '[EMAIL PROTECTED]' FAILED!! -- Test failed: Different values at index 1: 'Baz, Inc.' vs. 'Foo, Inc.': 'Baz, Inc.' ne 'Foo, Inc.' on /home/cxp/work/popup_sort/perl_lib/RTK/Retail/Product/TEST/Supplier.pm, line 34 Yikes!!. Errors in: /home/cxp/work/popup_sort/perl_lib/RTK/Retail/Product/TEST/Supplier.pm Let me know if anything is unclear. If you can think of any pros and cons of this approach, I would love to hear them. Cheers, Ovid ===== Silence is Evil http://users.easystreet.com/ovid/philosophy/indexdecency.htm Ovid http://www.perlmonks.org/index.pl?node_id=17000 Web Programming with Perl http://users.easystreet.com/ovid/cgi_course/ __________________________________ Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com