gaal has asked for the wisdom of the Perl Monks concerning the following question:
My application validates some record-based input it receives, and before doing any heavy processing on it generates a report on validation errors it may have encountered. The report is textual and should go to a file specified by the user (e.g. via a command line switch, with some reasonable default).
I'm testing the validation phase now, and want to take advantage of in-memory files (5.8.0 and onwards support open $fh, '>', \$file_in_ram) so that my test doesn't have to start messing with real files. I can make the file handle a field in the object I'm testing, but I can't figure out an elegant way to keep the file itself around and accessible to the test. Not any way that isn't horrendously ugly, anyway. Like for example adding a member to the object that is populated only during tests.
What's a reasonable way to approach this? Should I just forget it, write out the file, and read it back? (One reason I didn't want to do that is that I may want to inspect my data before closing it, and don't want to be bitten by buffering issues. Now that I think of it, though, the same issues can exist with an in-memory file.)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Test-specific members
by Realbot (Scribe) on Feb 28, 2005 at 12:40 UTC |