Sunday, April 3, 2011

Does anyone know of a good Perl unit test generator?

Does anyone know of a good Perl unit test generator?

From stackoverflow
  • EDIT: (Thanks to commentors)

    My original suggestion of PerlUnit is deprecated. Use Test::Class instead.

    Original Post:

    You could try PerlUnit. There is also a book chapter on unit testing in Perl: Extreme Perl: Chapter 13: Unit Testing

    jrockway : Use Test::Class if you want nUnit style testing.
    Ovid : PerlUnit was abandoned years ago and does not play well with Perl's standard testing tools. Test::Class is a better choice for this.
  • Not sure what you're asking, but most people write tests with Test::More or Test::Class. You then run these tests with the prove command included with Perl (actually, with Test::Harness).

    Example test:

    # foo.t
    use strict;
    use warnings;
    use Test::More tests => 1;
    
    ok( 1 == 1, 'is one one?' );
    

    Running this:

    $ prove foo.t
    
    foo....ok
    All tests successful.
    Files=1, Tests=1,  0 wallclock secs ( 0.01 usr  0.01 sys +  0.03 cusr  0.00 csys =  0.05 CPU)
    Result: PASS
    
  • If you're going to test web apps, Selenium IDE allows you to do stuff in firefox and have it automatically be recorded as an equivalent set of Perl (or other language) tests.

    While it doesn't test everything, it is good for testing the user experience.

    mpeters : The OP didn't say anything about web testing, so you can't assume that Selenium would be of any help.
    ysth : The OP didn't really say much to indicate what s/he was talking about at all. And certainly somebody may find this answer just what they were looking for someday. The "For web apps," at the beginning should clue in those not interested; that's why I started with it.
    innaM : Although he was indeed pretty cryptic, he did at least say that he wanted Unit tests. Selenium may be a cool framework, but it's give you integration tests.
    Neer : Thanks for the comments. The basic Idea of the question was to explore options of unit test generators for perl. I found j_random_hackers comment to my question as an answer. I also think my question was not cryptic but was not limiting the scope. In that sense the answer of Selenium IDE is legible [to my abstract question] .

0 comments:

Post a Comment