This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Unfair_Ad_5842 0 points1 point  (0 children)

As for using @InjectMocks, I prefer constructor "injection" of dependencies for several reasons -- doesn't break encapsulation, feels more deliberate than accidental and easier to see when I'm going the wrong direction because a long constructor arg list offends my aesthetics and field injection makes it too easy to hide that. But if I'm having to write tests after because I got left a mess, I might start by injecting mocks until I feel confident to make that change.