Closed GoogleCodeExporter closed 8 years ago
Hi
I don't think this is a good idea. Here is why:
> * a spy to the class-under-test
Spying the tested subject is weird, it doesn't make sense, but for partial
mocks which is most of the time a bad practice.
> * all primitive attributes set to their 1-values (e.g. int 1, float 1.0, char
' ', boolean true)
Initializing attribute to 1-value is wrong, we are bypassing the integrity of
the code under test on attributes whose usage is unknown.
> * all references referencing to mocks
If you need to have so many mock references, something might be wrong in your
design, check your 'Ce' (efferent coupling) metric in sonar. Besides with the
included short hand injection utility, that can instantiate the tested type
some conditions. Check the @InjectMocks javadoc there :
http://docs.mockito.googlecode.com/hg/latest/org/mockito/InjectMocks.html
However you might be interested by this project, which goes a bit further in
order to avoid knowledge on collaborators: http://code.google.com/p/komarro/
Original comment by brice.du...@gmail.com
on 5 Mar 2012 at 10:35
Original comment by brice.du...@gmail.com
on 3 Sep 2012 at 10:00
Original issue reported on code.google.com by
sebidiet...@gmail.com
on 5 Mar 2012 at 7:24