unit testing - Scoping variables in a Perl Test::More .t file -
is there way scope variables test::more tests in .t file? example:
# 1st test $gotresult = $myobject->runmethod1(); $expectedresult = "value1"; is($gotresult, $expectedresult, "validate runmethod1()"); #2nd test $gotresult = $myobject->runmethod2(); $expectedresult = "value2"; is($gotresult, $expectedresult, "validate runmethod2()"); #3rd test ...
i'm looking way discretely manage individual tests in .t file conflicts/errors not introduced if variable names reused between tests.
sal.
to expand on mirod's correct answer: may scope variables braces perl program, may take step further. test::more has concept of subtest, in define subref contains 1 or more tests run (and of course creating scope in process).
subtest 'subtest description here' => sub { # setup, tests ok 1, 'the simplest test'; };
Comments
Post a Comment