I am actually aware of PowerMock and have been playing with it,
however, I am also using OpenEJB and there seems to be a problem
integrating these two. Also I know you can always factor out
instantiation to a method or factory but this is not always possible
when working with legacy code.
Thanks for your thoughts everyone they have been helpful.
jg
On May 18, 12:06 pm, Kartik Kumar <
krishnan.1...@gmail.com> wrote:
> Even though it is a code smell, it is still possible to do it. You need a
> remapper framework. There is a framework called PowerMock that works on top
> of Mockito and EasyMock to provide this functionality. Take a look at this
> linkhttp://
code.google.com/p/powermock/wiki/MockitoUsage
>
> On Tue, May 18, 2010 at 8:16 AM, Chris Bartling <
chris.bartl...@gmail.com>wrote:
>
>
>
> > Javier,
>
> > You might want to step back and understand your design a little bit.
> > Mocking works best when your class under test does not take on the
> > responsibility of constructing its collaborators. If your class in your
> > current code base is taking on this responsibility, you should refactor that
> > responsibility to some method that you can overridden or a factory that you
> > can mock. Ultimately, you'd prefer to use *dependency inversion* (of
> > which *dependency injection* is one flavor of) to facilitate this
> > decoupling. Much looser coupling between your object under test and its
> > collaborators. One smell that I look for is the importing of concrete
> > classes. If you see this, in most situations its a sign that your class
> > knows too much about its collaborators.
>
> > Refactoring a code base to alleviate classes from construction
> > responsibilities is a common legacy smell. I've encountered it many times
> > and it's fairly straightforward to fix.
>
> >
http://en.wikipedia.org/wiki/Dependency_inversion_principle
>
> > <
http://en.wikipedia.org/wiki/Dependency_inversion_principle>
> >
http://en.wikipedia.org/wiki/Dependency_injection
>
> > <
http://en.wikipedia.org/wiki/Dependency_injection>
> >
http://butunclebob.com/ArticleS.UncleBob.PrinciplesOfOod
> >>
mockito+u...@googlegroups.com<
mockito%2Bunsu...@googlegroups.com>
> >> .
> >> > >> --
> >> > >> You received this message because you are subscribed to the Google
> >> Groups "mockito" group.
> >> > >> To post to this group, send email to
moc...@googlegroups.com.
> >> > >> To unsubscribe from this group, send email to
> >>
mockito+u...@googlegroups.com<
mockito%2Bunsu...@googlegroups.com>
> >> .
> >> > > --
> >> > > You received this message because you are subscribed to the Google
> >> Groups "mockito" group.
> >> > > To post to this group, send email to
moc...@googlegroups.com.
> >> > > To unsubscribe from this group, send email to
> >>
mockito+u...@googlegroups.com<
mockito%2Bunsu...@googlegroups.com>
> >> .
> >> > --
> >> > You received this message because you are subscribed to the Google
> >> Groups "mockito" group.
> >> > To post to this group, send email to
moc...@googlegroups.com.
> >> > To unsubscribe from this group, send email to
> >>
mockito+u...@googlegroups.com<
mockito%2Bunsu...@googlegroups.com>
> >> .
> >> --
> >> You received this message because you are subscribed to the Google Groups
> >> "mockito" group.
> >> To post to this group, send email to
moc...@googlegroups.com.
> >> To unsubscribe from this group, send email to
> >>
mockito+u...@googlegroups.com<
mockito%2Bunsu...@googlegroups.com>
> >> .
> >
mockito+u...@googlegroups.com<
mockito%2Bunsu...@googlegroups.com>
> > .