in reply to Re^2: How to share an object between test cases using Test::Harness
in thread How to share an object between test cases using Test::Harness

After testing a few serialization options including Data::Dumper, Storable and YAML. (Found an interesting article on these and others here:
http://www252.pair.com/comdog/mastering_perl/Chapters/14.persistence.html)
I came to the conclusion that the complexity of storing my connection data is not worth the effort ( ran into segmentation faults and other oddities).
In the end I decided to implement Elisheva's suggestion and run the test cases in a unified form as a single file. That way caching an object became a breeze. Also, I found a way to keep the files separated by making them Perl modules with a single exportable sub that run all tests in that module. A separated file "uses" all the modules and keeps the "memory" of previous tests, and I pass that file to TAP::Parser. Something like this:
# Main Program ... my $test_file = "MetaTester.pm"; my %args = ( source => $test_file ); my $parser = TAP::Parser->new( \%args ); while ( my $result = $parser->next ) { ... # Then in MetaTester.pm use Test1.pm; use Test2.pm; Test1::run_tests(); Test2::run_tests();
Thanks again to all that responded.
  • Comment on Re^3: How to share an object between test cases using Test::Harness
  • Download Code