Here is what I've got:
So says my simple test file. The module it is supposed to be exercising says this:1..2 ok 1 - use YMD::WWW::DB; not ok 2 - YMD::WWW::DB->can(...) # Failed test 'YMD::WWW::DB->can(...)' # at t/08-db.t line 14. # YMD::WWW::DB->can('We can access the ->connect() method') failed # Testing YMD::WWW::DB 0.01, Perl 5.008008, /var/usr/bin/perl # Looks like you failed 1 test of 2.
and the test itself reads:package YMD::WWW::DB; use warnings; use strict; use DBI; use Data::Dumper; sub connect { my $self = shift; my $db = shift; # print STDERR "->connect() says that \$db is: " . Dumper(\$db); my $db_driver = $db->{'db_driver'}; my $host_name = $db->{'db_host'}; my $db_name = $db->{'db_name'}; my $USER = $db->{'db_user'}; my $PASSWORD = $db->{'db_pw'}; my $dsn = "DBI:$db_driver:host=$host_name;database=$db_name"; if($db->{'db_ssl'}){ $dsn .= ';sslmode=require'; } # print $dsn,"\n"; return (DBI->connect($dsn,$USER,$PASSWORD, {PrintError => 0, RaiseError => 1})); } 1; # End of YMD::WWW::DB
I would think that my module->can('method'), even if I haven't yet built the config hash to pass it on its interface. Any clues what I might be missing here, please?#!perl -T use Test::More tests => 2; use lib qw{/home/hesco/sandbox/YMD-WWW-SamplePhoneCall/lib}; BEGIN { use_ok( 'YMD::WWW::DB' ); } use YMD::WWW::DB; can_ok('YMD::WWW::DB','connect','We can access the ->connect() method' +); diag( "Testing YMD::WWW::DB $YMD::WWW::DB::VERSION, Perl $], $^X" );
-- Hugh
UPDATE:
Thanks folks, that was exactly it. I found and corrected three other bugs in this code simply preparing this post, but it never occurred to me to perldoc Test::More for the can_ok function. I just assumed I knew how to use that one. Thanks again. I'll get back to work on this project after getting some groceries in the house.
In reply to Can't find my method . . . by hesco
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |