| Author |
mocking deep down with mockito
|
Wendy Gibbons
Bartender
Joined: Oct 21, 2008
Posts: 1098
|
|
How do I write a test where the class I need to mock isn't static, and is deep down in the bowls of my application?
sorry I haven't got very far at all yet in my research.
|
 |
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 26499
|
|
Wendy,
This question is hard to answer without an example. On a high level, you abstract something or subclass or ...
Can you provide an example?
|
[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
|
 |
Wendy Gibbons
Bartender
Joined: Oct 21, 2008
Posts: 1098
|
|
Ther problem is that all of our code is called by reflection, with intefaces decided years ago. So nothing can be passed in the constructors.
Yesterday I was trying to mock the ElementTemplateMasterService to return a new response. But with this mornings refactor I am only trying to maock the FlexifieldMaster, but it is still an object I have no control over the instantiation of.
This is the test I am trying to fix (currently in progress trying to sort out an answer):
this is the method I am trying to stub out (on FlexiFieldMaster)
|
 |
Wendy Gibbons
Bartender
Joined: Oct 21, 2008
Posts: 1098
|
|
well with help I got the previous version to work using doReturn, but then other code after the call caused problems, so I had to stub even higher up and endud up using doNothing.
So my question has become, Is there any good documentation that actually documents this without presuming you are a master of easyMock just converting?
|
 |
 |
|
|
subject: mocking deep down with mockito
|
|
|