On 7/20/06, Hakim Cassimally <[EMAIL PROTECTED]> wrote:
Restructuring your tests (moving OS-dependent, skippable sections to
their own scripts for example) might make the requirement for a
deferred plan seem less important ?

Writing tests is harder. Writing code is more rewarding to the heart.
It is good to have simple ways to write tests, and if they can be
tighter with little effort, even better. Sometimes, I would like to
have something like that below so that I don't need to think about how
to compute the number of tests beforehand:

use Test::More;

subplan tests => 2;

require_ok('MyModule');
my $obj = MyModule->new();
isa_ok($obj, 'MyModule');

my  @cities = ("Brasilia", "Rio de Janeiro", "Salvador");

subplan tests => [EMAIL PROTECTED];

for (@countries) {
    ok(is_hot($_), "$_ is hot");
    ok(me_fits($_), "$_ is nice to me");
}

end_of_plan;

generating TAP-like output like this

1..2..
ok 1 - require MyModule
ok 2 - The object isa MyModule
3..8..
ok 3 - Brasilia is hot
ok 4 - Brasilia is nice to me
ok 5 - Rio de Janeiro is hot
ok 6 - Rio de Janeiro is nice to me
ok 7 - Salvador is hot
ok 8 - Salvador is nice to me
..THE END

When I tried to think about a TAP-emitting library for (argh) Java,
that made sense because tests would need to be within methods anyway,
as every Java code is. To have a count to each test method would be
easy, but to have an overall plan seemed a headache.

Reply via email to