开发者

How do I use the Test::Unit::TestCase Perl CPAN module?

开发者 https://www.devze.com 2023-02-10 16:13 出处:网络
I have the following file: #!/usr/bin/perl use Test::Unit::TestCase; $self->assert(1) and when I run test.pl I get the following:

I have the following file:

#!/usr/bin/perl
use Test::Unit::TestCase;
$self->assert(1)

and when I run test.pl I get the following:

Can't call method "assert" on an undefined value at ./parse.pl line 3.

I ran sudo perl -MCPAN -e 'install Test::Unit' and the module seemed to be installed correctly (especially since I get no error on the use statement), but I don't know how to actually u开发者_JAVA百科se the module.


Did you try copying the code sample from the documentation? (see perldoc Test::Unit::TestCase on the command line.)

Your first problem that you are getting warnings about is that $self has not been initialized. A second problem is that you are not using strict, which would have given you a clearer warning. A third problem is that you are not inheriting from the module. The code sample in the documentation will solve the first and third problems, and the second is something that should become a habit.

0

精彩评论

暂无评论...
验证码 换一张
取 消