in reply to Re^2: Testing Perl Package
in thread Testing Perl Package

I think the first step would be for you to make statements about what your package is supposed to be or do.

An example could be the statement "The module compiles".

A better example would be statements on the meaning of the data in your module. Maybe "Every machine has a positive number of CAN_NETWORK_INTERFACES".

The second step is then to write programs that check that these statements are true. This is where Test::Tutorial comes in.

With which of the two steps do you have problems? What are these problems?

Replies are listed 'Best First'.
Re^4: Testing Perl Package
by nlalitha (Initiate) on May 10, 2013 at 09:15 UTC

    Hi,

    Thanks for the comments.

    i am testing the package with the Test::more module, see the below code,

    #!/usr/bin/perl -w use strict; use SptTgtCfg; use Test::More; BEGIN { use_ok('SptTgtCfg'); } $SptTgtCfg = SptTgtCfg::Max_Num_Of_Interest_Mask->new(CAN11 => 4,C +AN29 => 4); ok( defined $SptTgtCfg, 'new() returened something' ); ok( $SptTgtCfg->isa('SptTgtCfg'), " and it's the right class" ); is( $SptTgtCfg->CAN11, 7, ' CAN11()' ); is( $SptTgtCfg->CAN29, 2, ' CAN29)' );

    whether i am doing correct or not, please suggest. If i run this code, i am getting error as

    1. ok 1 - use SptTgtCfg;

    2. Gllobal symbol requires explicit package name

      I highly doubt that your package SptTgtCfg is valid Perl and compiles as is. Thus I really doubt that you ever see

      ok 1 use SptTgtCfg;

      Your code cannot progress that far, because the line

      use SptTgtCfg;

      already fails.

      Consider reading the error message and looking at the line number that it indicates. Then consider what variables are on that line and where they are declared.

      Update: My diagnosis is somewhat wrong. My mistake here was to assume that SptTgtCfg.pm contains the errors as shown in the root node. But obviously, the ok 1 message can appear with a correct module SptTgtCfg.pm and then later the program hits the (strict induced) error of $SptTgtCfg not being declared.

      Your script starts with strict. You cannot assing to the undeclared variable $SptTgtCfg under strict.
      لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
      Well, the code you posted in Testing Perl Package contains only a bunch of global hashes, it contains no methods/functions/subs, especially none called new/CAN11...

        Hi,

        May be my understanding wrong, could you please provide some examples other than mentioned in the CPAN Module.

        How to use "Test::more" module to our package which is local