Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Testing: Fun for the family

by Corion (Pope)
on Mar 09, 2004 at 10:17 UTC ( #335048=note: print w/ replies, xml ) Need Help??


in reply to Testing: Fun for the family

The functions that Test::More exports are already somewhat closer to "english", as it exports is ("smart" equality), like (regex matching), and even is_deeply (equality for arrays).

I guess an "informal" specification could to go a route of first defining Perl equivalents for some expressions and then simply translating some simplicistic sentences into Perl, possibly like the following:

=for test_description Description: The foo parameter contains valid data. Definitions: The foo parameter is stored in $foo. Criteria: The foo parameter is not empty and The foo parameter is defined and The foo parameter matches the pattern C</bar/>. =cut

This could ("easily") be compiled into the following Perl code:

my %test; my $foo; $test{Description} = qw(The foo parameter contains valid data); # The foo parameter is stored in $foo. $test{access} = [ \$foo ]; # The foo parameter is not empty and for my $t (@{$test{access}}) { isnt( $t, '', $test{Description} . qw(The foo parameter is not empty)) +; # The foo parameter is defined and is( $t, defined, $test{Description} . qw(The foo parameter is defined) +); # The foo parameter matches the pattern C</bar/>. like( $t, qr/bar/, $test{Description} . qw(The foo parameter matches C +</bar/>)); };

As long as you restrict yourself to this simple vocabulary, this would do the job, and possibly you will want to create "macros" that allow you a higher-level description of the specifications. But I think that describing the single tests in english dosen't buy you much in the sense of readability and understanding, as it dosen't describe the "top view" but only the single small steps towards the main goal.


Comment on Re: Testing: Fun for the family
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://335048]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (15)
As of 2014-07-25 16:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (174 votes), past polls