anurag_perl has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

Can anyone tell on how to execute a number of testcases i.e. TC's.Example I have certain number of TC's as sub-routines in a .pl file such that my program should execute this file and tell me how many TC's passed,failed,pass percentage as a result.

Regards,

Anurag

Replies are listed 'Best First'.
Re: How to create testcase executor?
by jethro (Monsignor) on Dec 22, 2011 at 11:58 UTC

    The best advice I can give you is to get and read the book "Perl Testing. A Developer's Notebook" published by O'Reilly. Alternatively just google for "perl testing" and you will find lots of information about that topic.

      But instead of going through the book, are there any perl cpan modules for quick reference to develop.
        A reply falls below the community's threshold of quality. You may see it by logging in.
Re: How to create testcase executor?
by Your Mother (Archbishop) on Dec 22, 2011 at 14:20 UTC

    What everyone said already. Testing in Perl is really quite easy.

    # some-test.t use strict; use Test::More; ok(1, "1 is okay"); is("A", "A", "A is A"); cmp_ok("B", "gt", "A", "B is greater than puny A"); isnt("A", "B", "A didn't magically become B"); like("this", qr/that/, "This is like that"); done_testing(5);
    moo@cow[326]~>prove some-test.t -v some-test.t .. ok 1 - 1 is okay ok 2 - A is A ok 3 - B is greater than puny A ok 4 - A didn't magically become B not ok 5 - This is like that 1..5 # Failed test 'This is like that' # at ab.t line 7. # 'this' # doesn't match '(?-xism:that)' # Looks like you failed 1 test of 5. Dubious, test returned 1 (wstat 256, 0x100) Failed 1/5 subtests Test Summary Report ------------------- ab.t (Wstat: 256 Tests: 5 Failed: 1) Failed test: 5 Non-zero exit status: 1 Files=1, Tests=5, 0 wallclock secs ( 0.02 usr 0.00 sys + 0.01 cusr + 0.00 csys = 0.03 CPU) Result: FAIL

    More reading: prove (App::Prove), Test::Simple, Test::More, Test::Fatal, and many, many more for specific applications like Test::WWW::Selenium.

Re: How to create testcase executor?
by educated_foo (Vicar) on Dec 22, 2011 at 13:30 UTC
    You probably want to use something like Test::Simple, which provides a simple interface and plays well with the rest of Perl's testing modules.