Java Mailing List Archive

http://www.gg3721.com/

Home » user.jmock »

[jmock-user] Setting dependencies in servlets

diyfiesta

2009-08-03

Replies: Find Java Web Hosting

Author LoginPost Reply
Hello,

Probably a silly question really but what's the preferred way to set dependencies on a servlet so they can be mocked? Usually, I'd set them on the constructor of some object and have the servlet delegate to that object but I find myself writing an integration type test where the servlet itself is being tested... I'm assuming you'd set any configuration (ie the dependancies) on the servlet context and mock some servlet API call to return the mocked dependency? I'm wondering if I've forgotten some nifty trick though as that just seems clunky!

Cheers,
--
Toby
©2008 gg3721.com - Jax Systems, LLC, U.S.A.