psantann has asked for the wisdom of the Perl Monks concerning the following question:
# Tester.pm - Loads test cases#!/usr/bin/perl use strict; use warnings; use TAP::Parser; use Tester; Tester::main();
# file1 - First test case#!/usr/bin/perl use strict; use warnings; use TAP::Parser; package Tester; our $one = 1; sub main { my @test_files = qw( file1 file2 ); for my $file ( @test_files ) { my %args = ( source => $file, test_args => [ arg1 => 'arg1' ], # Not used for ilustr +ation only ); my $parser = TAP::Parser->new( \%args ); while ( my $result = $parser->next ) { print $result->as_string, "\n"; } } } sub get_one { return $one; } sub set_one { my $class = shift; $one = shift; } 1;
# file2 - second test case (fails $one is reset to 1)#!/usr/bin/perl use strict; use warnings; use Test::More 'no_plan'; use Tester; Tester->set_one(1); my $one = Tester->get_one(); Tester->set_one(2); # Try to set this for the next test Test::More::is( $one, 1, 'One equals to one' );
#!/usr/bin/perl use strict; use warnings; use Test::More 'no_plan'; use Tester; Tester->set_one(1); my $one = Tester->get_one(); Tester->set_one(2); # Try to set this for the next test Test::More::is( $one, 1, 'One equals to one' );
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to share an object between test cases using Test::Harness
by ELISHEVA (Prior) on Feb 25, 2011 at 12:04 UTC | |
by Anonymous Monk on Feb 25, 2011 at 12:07 UTC | |
by psantann (Novice) on Feb 25, 2011 at 17:34 UTC | |
by psantann (Novice) on Feb 25, 2011 at 23:22 UTC | |
|
Re: How to share an object between test cases using Test::Harness
by mellon85 (Monk) on Feb 25, 2011 at 05:00 UTC | |
by psantann (Novice) on Feb 25, 2011 at 17:24 UTC |