-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do not use @Autowired private variables #5
Comments
List found with
|
peterjaschke
pushed a commit
that referenced
this issue
Jun 22, 2020
peterjaschke
pushed a commit
that referenced
this issue
Jun 23, 2020
Think also got fixed. And for sure, to mention the autowired in Haven't yet saw the this lombok framework yet, but does a good job. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Please do not use
@Autowired
on private variables.This makes it more or less impossible to implement nice unit tests.
(At least from my experience with spring framework)
Use auto injection into the constructor, so in a unit test the constructor can given a dummy service and it is not needed to deal with changing private variables.
ref to unit tests: #3
If I'm wrong please provide an example unit test how to replace the injected bean.
edit: don't whant to refer to a user, so quoted
@Autowired
The text was updated successfully, but these errors were encountered: