Re: Writing our own modules in Test2
Buddy Burden <[email protected]> Fri, 24 Jun 2016 14:41:29 -0700
| Newsgroups | gmane.comp.lang.perl.quality-assurance |
|---|---|
| Message-ID | <[email protected]> |
Andy,
> I=92ve accumulated a number of test functions in our work codebase for
> doing what I call =93expressive=94 tests to avoid common cut & paste. =
I=92m
> using the term =93expressive=94 for now because they=92re expressing wh=
at it
> is you want, rather than making you write the code that explains them.
Sounds good. I would definitely use such a module.
> is_empty_array( $foo );
> is_nonempty_array( $foo );
>
> because I believe that it=92s easier to read the English =93is empty ar=
ray=94
> than to translate =93is( scalar @{$foo}, 0 )=94 into that meaning.
*Plus* it gives you an opportunity to display better diagnostics. E.g.=20
"okay, test failed, so the array's not _empty_ ... but what the hell is=20
in it?" This is exactly why I wrote:
is_true($val);
is_false($val);
Because with just `ok($val)` you can tell whether it's true or false,=20
but, when it inevitably fails, you really want to know what the bad=20
value turned out to be.
Anywho, things like this are, as you say, simple to write, but valuable=20
in several different ways.
-- Buddy