Yeah, this is way we write our pages. The pages are very lightweight and normally just call services. The services are separately unit tested. The problem is being able to test if the page actually calls the service.
On Mon, 2006-04-10 at 11:30 -0400, James Carman wrote: > That's kind of the idea behind T4 and the HiveMind integration. Pages > should just collect information from the user and pass that information to > services to actually do the work (and then present results back to the user > of course). That way, your pages are more lightweight and view-oriented > only. Using this paradigm, it's very easy to unit test your application > logic outside the container. > > -----Original Message----- > From: James Carman [mailto:[EMAIL PROTECTED] > Sent: Monday, April 10, 2006 11:28 AM > To: 'Tapestry users' > Subject: RE: [OT] test case for pages that email > > So, make your page call a service which does all the work. Then, you can > easily test a service object outside the container using mock objects. > > -----Original Message----- > From: Dan Adams [mailto:[EMAIL PROTECTED] > Sent: Monday, April 10, 2006 11:26 AM > To: Tapestry users > Subject: RE: [OT] test case for pages that email > > I would love to use a mock object for this, but I'm not sure of a way to > instantiate a page class in order to test it. We use mock objects > extensively elsewhere but I don't know how to set up a tapestry page to > test it. > > On Mon, 2006-04-10 at 11:19 -0400, James Carman wrote: > > 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]