jeudi 22 janvier 2015

How can I mock a subroutine for Unit testing in Perl?

Here I am giving the psudocode for for the subroutine which need unit testing to be done.



sub get_detail_team(param1,param2){

my $dbh = connect to databasehandle
my sql = get_sql_details(param1,param2)
my $sth = $dbh->prepare($sql)
$sth->execute()
my $result = $sth->fetchall_arrayref();

return get_html_content($result,prama)
}


the get_sql_details() and get_html_content() are also the sub routines which are in the same package. How can we unit test the get_detail_team() function?


I have tried using this Test::Mockmodule but did not get the excat results.


Aucun commentaire:

Enregistrer un commentaire