I would use MockObjects for this and the second line would be something
like:

emailService.sendEmail( params );

Then, you give it a mock emailService and make sure it calls it.

-----Original Message-----
From: Dan Adams [mailto:[EMAIL PROTECTED] 
Sent: Monday, April 10, 2006 11:16 AM
To: Tapestry users
Subject: RE: [OT] test case for pages that email

No no. Okay lets say I have some code in the page that does this:

displayMessage();
sendEmail();

How do you write a unit test that makes sure that the page actually
calls the second line? You could take it out and still have the tests
pass.

I found a lightweight email server at
http://www.ericdaugherty.com/java/mailserver that looks like it could
use that.

On Mon, 2006-04-10 at 10:52 -0400, James Carman wrote:
> You don't typically unit test a mail server.  That's a
> deployment/configuration issue.  If you're using JavaMail or Jakarta
Commons
> Email to send your emails, you can be pretty sure that the emails will go
> out if your mail server is available and configured properly.
> 
> -----Original Message-----
> From: Dan Adams [mailto:[EMAIL PROTECTED] 
> Sent: Monday, April 10, 2006 10:50 AM
> To: Tapestry users
> Subject: Re: [OT] test case for pages that email
> 
> Well, my page is going to display a message to the user letting them
> know but that doesn't ACTUALLY mean that the email was sent or the
> service was called. The way I have to do it right now is by having the
> email sent to me and checking my email manually. I would love to have it
> all automated though.
> 
> On Mon, 2006-04-10 at 10:45 -0400, Mike Snare wrote:
> > Well, wouldn't you want to indicate to the user that the send was
> > successful or not?  If so, you could just look for that.  I know you
> > said that the submission doesn't affect the page but don't you want to
> > let the user know it worked?
> > 
> > -Mike
> > 
> > On 4/10/06, Dan Adams <[EMAIL PROTECTED]> wrote:
> > > Okay, I have a page that, when submitted, sends an email. Now the page
> > > uses a service via interface that actually does the emailing and that
> > > service is tested separately. But how can I write a test that makes
sure
> > > that my page actually calls that service and that the email gets sent
> > > since that doesn't effect the page in any way that i can test for
using
> > > htmlunit? Does anyone know of a lightweight mail server analogous to
> > > jetty/hsqldb that i could use for testing?
> > >
> > > --
> > > Dan Adams
> > > Software Engineer
> > > Interactive Factory
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > For additional commands, e-mail: [EMAIL PROTECTED]
> > >
> > >
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > 
-- 
Dan Adams
Software Engineer
Interactive Factory


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to