I am trying to be good this time and write unit tests using Test::More. A number of my methods return XML and I wish to write a subtest that verifies the XML data and which can be called a number of times with different parameters.
How do I pass parameters to the subtest? Updates and progress is below:
Best solution (so far): seems to be to use a wrapper method containing an anonymous subtest routine, passing the parameters to the wrapper.
sub my_wrapper { my ($name, $xml) = @_; subtest 'My subtest' => sub { like( $xml, qr/xml version=/, "$name: XML Document"); }; } my $m1Xml = MyPackage::method1(); my_wrapper( 'Method 1 XML', $m1Xml); my $m2Xml = MyPackage::method2(); my_wrapper( 'Method 2 XML', $m2Xml);
In reply to Test::More subtest parameters by space_monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |