Perl Module Testing Scipt

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • megri
    Administrator

    • Mar 2004
    • 1167

    Perl Module Testing Scipt

    I am currently working on a custom Perl module and want to ensure my unit tests follow modern best practices. I've put together a test script using Test::More and Test::Exception, but I want to make sure I am handling object construction, edge cases, and test planning correctly.
    Could you take a look at my script structure and let me know if there is anything I should optimize, or if I should look into moving to Test2::V0 instead?



    Code:
    #!/usr/bin/perl
    
    print "Content-Type: text/plain; charset=UTF-8\r\n\r\n";
    
    my @modules = (
        'LWP::UserAgent',
        'LWP::Protocol::https',
        'HTTP::Request',
        'URI',
        'IO::Socket::SSL',
        'Mozilla::CA'
    );
    
    foreach my $module (@modules) {
        eval "require $module;";
    
        if ($@) {
            print "$module: NOT AVAILABLE\n";
            print "Reason: $@\n\n";
        }
        else {
            no strict 'refs';
            my $version = ${"${module}::VERSION"} || 'version unknown';
            print "$module: AVAILABLE ($version)\n";
        }
    }
    Parveen K - Forum Administrator
    SEO India - TalkingCity Forum Rules - Webmaster Forum
    Please Do Not Spam Our Forum
Working...