in reply to Writing a module test
I'd probably refactor QuizTaker to add a Games::QuizTaker::IO module which implements the extremely simple methods in and out
sub in { return scalar <STDIN>; } sub out { print @_; }
You can then use Test::MockObject to mock G::QT:IO during your testing of the "test" method and pass data in/out as you want.
If you're not so much into mocking objects you could also fork the test and pass the data into your child from the test, or you could put the "test" call into a separate little script and run that via Test::Expect but IMO that's more convoluted. YMMV.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Writing a module test
by TStanley (Canon) on Jun 09, 2007 at 21:00 UTC |