sub new { my ($class) = @_; # Initialize attributes my $self = { _test_name => undef, # Name of the current test _testcase_name => undef, # Name of the current testcase _test_statistics => {}, # Statistics for the current test }; bless $self, $class; # Two-argument version used to support inheritance return $self; } #### sub run_test{ my ($self, @tests) = @_; # Setup test system. $self->_setup_test_system(); # Run each test. TEST: for my $test_name (@tests) { # Setup everything necessary for current test. $self->setup_test_system($test_name); # Run each testcase for current test. TESTCASE: while ($self->__fetch_next()){ my $start = gettimeofday(); my $is_pass = $self->_run_testcase(); my $end = gettimeofday(); my $duration = $end - $start; if (!$is_pass && $self->{_abort_on_failure}) { print "\nFailure occurred,for $test_name.\n"; last TESTCASE; # Exit loop } } # Cleanup at end of test. $self->cleanup_test(); # Clean up test system. $self->_cleanup_test_system(); return $self->{_test_system_stats}{num_tests_failed}; } }