When I encounter something like this, I usually just temporarily override the
function/method that
actually sends the mail:
my $email_text;
my $mail_func = 'My::Mail::Module::send';
{
no warnings 'redefine';
local *$mail_func = sub { $email_text = shift };
}
ok($email_text, "$mail_func should be called called");
is($email_text, $test_text, '... and the email should match the sample text');
The above, of course, is probably not as complete as you might want for production
code, but it's
roughly how I would approach the situation.
Cheers,
Ovid
--- Mark Stosberg <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I'm looking at writing a test for an e-mail that's generated by Perl.
> I'm wondering about the best way to do this. Here are some possibilities
> I have considered:
>
> - use Test::Mail. While it's designed for the task, I'm not fond of the
> complexity of setting up an e-mail address which sends the input to
> a test script, which generates a log file that someone eventually
> sees.
>
> - Test the message at the moment before it's sent. For this I thought
> Test::AtRunTime might be a good choice. The output could be a
> sent to a logfile that some other test script output could remind
> me to read...or perhaps even open for me.
>
> - ??
>
> I'm curious to know what others are doing to address this that they have
> been satisfied with.
>
> Thanks!
>
=====
Silence is Evil http://users.easystreet.com/ovid/philosophy/indexdecency.htm
Ovid http://www.perlmonks.org/index.pl?node_id=17000
Web Programming with Perl http://users.easystreet.com/ovid/cgi_course/
__________________________________
Do you Yahoo!?
Exclusive Video Premiere - Britney Spears
http://launch.yahoo.com/promos/britneyspears/