Scopri come testare i tuoi esercizi di Perl su Exercism
C'è uno script Perl con estensione .t nella directory t/, che verrà usato per testare la soluzione.
Puoi eseguire i test con il comando:
prove
Prima di iniziare l'esercizio, l'output sarà probabilmente simile a questo:
./t/hello-world.t .. 1/2
# Failed test 'Say Hi!'
# at exercises/hello-world/t/hello-world.t line 15.
# +---------+---------------+
# | GOT | CHECK |
# +---------+---------------+
# | <UNDEF> | Hello, World! |
# +---------+---------------+
exercises/hello-world/t/hello-world.t .. Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/2 subtests
Test Summary Report
-------------------
./t/hello-world.t (Wstat: 256 Tests: 2 Failed: 1)
Failed test: 2
Non-zero exit status: 1
Files=1, Tests=2, 0 wallclock secs ( 0.03 usr 0.00 sys + 0.18 cusr 0.02 csys = 0.23 CPU)
Result: FAIL
Dovrai modificare il modulo con estensione .pm contenuto nella directory lib/ e scrivere una soluzione che superi i test.
Una volta che i test passano, l'output del comando qui sopra sarà probabilmente simile a questo:
./t/hello-world.t .. ok
All tests successful.
Files=1, Tests=2, 0 wallclock secs ( 0.02 usr 0.00 sys + 0.07 cusr 0.01 csys = 0.10 CPU)
Result: PASS
La documentazione sulle affermazioni usate nei file di test si trova in Test2::Manual::Testing::Introduction.
Puoi trovare una spiegazione più approfondita di Test2 su perldoc.