on 02-01-2018 4:22 PM
I'm testing a class in an integration test which sends Events using the EventService bean. Since events are async and (seem) super hard to test I want to mock out the EventService dependency in my class. All other dependencies should be resolved as is.
I know that I can simply inject my class with the @Resource annotation und then use setter injection, however:
Mocks are not removed from the injected beans if you use setter injection. This causes other integration tests to fail if they reuse the same bean and expect a working version. I've resorted to injecting the original bean in the tearDown method to fix this.
I'd like to use constructor injection without defining explicit setters
Since Hybris customizes the test runner pretty heavily I'm at a loss how to integrate common Spring solutions like http://www.baeldung.com/injecting-mocks-in-spring
User | Count |
---|---|
5 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.