Perl ट्रैक पर टेस्टिंग

Exercism पर अपने Perl अभ्यासों की जाँच करना सीखिए।


सभी टेस्ट चलाइए

t/ डायरेक्टरी में .t एक्सटेंशन वाली एक Perl स्क्रिप्ट होती है, जिससे आपके हल का टेस्ट किया जाएगा। आप इस कमांड से टेस्ट चला सकते हैं:

prove

अभ्यास शुरू करने से पहले आउटपुट कुछ ऐसा दिखेगा:

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

टेस्ट पास करने के लिए आपको lib/ डायरेक्टरी में मौजूद .pm एक्सटेंशन वाले मॉड्यूल में बदलाव करना होगा और एक हल लिखना होगा। टेस्ट पास हो जाने के बाद ऊपर वाले कमांड का आउटपुट कुछ ऐसा दिखेगा:

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

टेस्ट फाइलों में इस्तेमाल हुए असर्शनों के बारे में डॉक्युमेंटेशन Test2::Manual::Testing::Introduction में मिल सकता है। Test2 की और गहराई में जाने वाली जानकारी perldoc पर मिल सकती है।