The stupid question is the question not asked | |
PerlMonks |
Re: How do i Unit Test a subroutineby choroba (Cardinal) |
on Jan 26, 2015 at 18:13 UTC ( [id://1114548]=note: print w/replies, xml ) | Need Help?? |
Sometimes, to make your code testable, you have to refactor it. The subroutine you showed is a good candidate:
Testable subroutine should only do one thing. The one you showed does three: connects to a database (read about "mocking"), constructs a SQL string, htmlizes the result.
لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
In Section
Seekers of Perl Wisdom
|
|