in reply to Re^2: Testing and combinations
in thread Testing and combinations

A series of next if ...s sounds like hard work for maintenance if there are more than a few of them. Sketch out your code and post it here if it looks like becoming unwieldy.

The main thing to consider is that you should be able to handle option lists of arbitrary length without needing to alter the test code. Also you should be able to specify the domain of valid option combinations in the table and have the test code generate the permutations without having to author each case in the test code.


Perl is environmentally friendly - it saves trees

Replies are listed 'Best First'.
Re^4: Testing and combinations
by talexb (Chancellor) on Oct 30, 2007 at 20:57 UTC
    my $testNum = 1; for my $thisFile ( undef, 'triple.zip' ) { for my $thisListLength ( qw/0 1 3/ ) { my $testName = "Test-$testNum"; $testNum++; diag "Test $testName with " . (defined($thisFile) ? $thisFile : 'no file') . " and list length $thisListLength"; my $args = { name => $testName }; $args->{'filename'} = $thisFile if (defined($thisFile) ); my $doc = XYZ::SuperDocument->create($args); ok(defined($doc), "$testName object created"); # TODO: Add list stuff as well. _testObject($doc,$args); } }

    Here's what I have so far .. the lists are hard-coded for now, but I will move them to a common location. This is the create loop, and later in another scope I have load, test and delete operations inside an identical loop.

    Alex / talexb / Toronto

    "Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds