space_monk has asked for the wisdom of the Perl Monks concerning the following question:
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);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Test::More subtest parameters
by Khen1950fx (Canon) on Apr 17, 2013 at 10:39 UTC | |
by space_monk (Chaplain) on Apr 17, 2013 at 11:43 UTC | |
by choroba (Cardinal) on Apr 17, 2013 at 12:17 UTC | |
|
Re: Test::More subtest parameters
by kcott (Archbishop) on Apr 17, 2013 at 16:51 UTC | |
|
Re: Test::More subtest parameters
by Anonymous Monk on Apr 17, 2013 at 09:14 UTC | |
by tobyink (Canon) on Apr 17, 2013 at 10:23 UTC |