exercism/perl5

Use Test2::Bundle::More for transition to Test2

m-dango opened this issue · 4 comments

Allow tests to look for Test2::Bundle::More, and failing that, fall back to Test::More, while advising the user to install Test2::Suite.

Opting to skip the fall back step and migrate straight to Test2::Bundle::More

The changes are on branch https://github.com/exercism/perl5/tree/test2-more, however we need to document how to install Test2::Suite before we merge these changes into master

What does Test2::Suite offer the average exercise test set?

IMO, Test2 has a much better output for diagnosing failing tests, for example:

perl -MTest::More -E 'is_deeply([split //, "banana"], [split //, "BaNaNa"]), done_testing'
not ok 1
#   Failed test at -e line 1.
#     Structures begin differing at:
#          $got->[0] = 'b'
#     $expected->[0] = 'B'
1..1
# Looks like you failed 1 test of 1.

We were given the first element of the array that failed, even though there are subsequent issues they weren't reported.

perl -MTest2::V0 -E 'is([split //, "banana"], [split //, "BaNaNa"]), done_testing'
# Seeded srand with seed '20190508' from local date.
not ok 1
# Failed test at -e line 1.
# +------+-----+----+-------+
# | PATH | GOT | OP | CHECK |
# +------+-----+----+-------+
# | [0]  | b   | eq | B     |
# | [2]  | n   | eq | N     |
# | [4]  | n   | eq | N     |
# +------+-----+----+-------+
1..1

All problematic elements in the array were reported, with their index, and what comparison was used.

Test2 eliminates the need to write tests using is, is_deeply, or cmp_ok and simply has it all under is (or like if you want a less strict comparison).

Test2 includes subroutines for exception testing, whereas with Test::More you typically have to include an additional module.