in reply to Re: How do i Unit Test a subroutine
in thread How do i Unit Test a subroutine
this the overview of the code. Now how can we mock this module to test each of the functions.Package Team use strict: use warnings; use DBI sub get_detail_team{ my ($team,$debug)=@_; my $dbh = connect to databasehandle my sql = get_sql_details($team,$debug) my $sth = $dbh->prepare($sql) $sth->execute() my $result = $sth->fetchall_arrayref(); return get_html_content($result,prama) } sub get_sql_details{ my ($team,$debug) = @_ my sql = "select id ,org,architec from table where team='$team" return $sql } sub get_html_content{ my ($result,$debug) = @_; return '<br><br>Could not locate architects.' if( scalar @$result == 0 + ); my $html =<br> <table> <th>Id</th><th>... foreach my $result_html(@result){ my ($id,$org,$architect) = @result_html $html.= <td>$id>... return $html; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: How do i Unit Test a subroutine
by Laurent_R (Canon) on Jan 23, 2015 at 22:07 UTC |