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

I'm setting options by adding things to an arg hash, and I am currently using a table to select my two test cases, one without a file, and the other one with. I also have an option that includes specifing a list, and I want to be able to specify a null list, a one element list or a three element list.

I think I'll use your suggestion of basing it on tables, and pre-populate my tables so that the first entry is 'nothing'; then I just use a serious of next ifs to try all of the different combinations.

Alex / talexb / Toronto

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

Replies are listed 'Best First'.
Re^3: Testing and combinations
by GrandFather (Saint) on Oct 30, 2007 at 20:46 UTC

    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
      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