Multiple expected values


dice() returns a whole number between 1-6.

In the application we have a function that can return any one of a list of possible values. In our example we have a dice() function that throws the dice. It should return a whole number between 1-6.

examples/test-perl/t/dice_cmp_ok.t
use strict;
use warnings;

use MyTools;

use Test::More tests => 2 * 4;

for (1..4) {
    my $value = dice();
    cmp_ok $value, '>', 0, 'bigger than 0';
    cmp_ok $value, '<', 7, 'smaller than 7';
}

perl examples/test-perl/t/dice_cmp_ok.t


1..8
ok 1 - bigger than 1
ok 2 - smaller than 6
ok 3 - bigger than 1
ok 4 - smaller than 6
ok 5 - bigger than 1
ok 6 - smaller than 6
ok 7 - bigger than 1
ok 8 - smaller than 6

It seems to be ok but we are actually not testing the correct thing. We should check if the result is one of the following values (1, 2, 3, 4, 5, 6)