Make @SpringMock work for beans with @Primary#1503
Conversation
fixes spockframework#1502 When the context contains multiple beans for given interface but one of them is marked as @primary it should be possible to mock this interface. Current implementation doesn't check if one of found beans is primary and fails with an exception. My change mirrors a similar logic used in spring-boot-starter-test and resolves this issue.
|
Could you also check if there are other relevant new additions that were made to |
…nces Additional assertions in new tests are commented as depepnding on whether tests are run with :test or :testCglib they either pass or fail with "org.opentest4j.MultipleFailuresError: Multiple Failures (2 failures)" exception - one failure being CannotCreateMockException and the other one the actual context loading problem.
I found four bugfixes applied to the
Apart from them there were ~4 PRs with refactorings/code polishing. I'll port the fix for 29639 here. |
6bc8f6c to
ddd2b4c
Compare
This change follows changes made in Spring Boot's MockitoPostProcessor.
|
Hi @leonard84 |
Codecov Report
@@ Coverage Diff @@
## master #1503 +/- ##
============================================
+ Coverage 79.76% 79.81% +0.04%
- Complexity 4047 4051 +4
============================================
Files 412 412
Lines 12779 12795 +16
Branches 1652 1656 +4
============================================
+ Hits 10193 10212 +19
+ Misses 1988 1985 -3
Partials 598 598
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
leonard84
left a comment
There was a problem hiding this comment.
Thanks for the fix @konradczajka
fixes #1502
When the context contains multiple beans for given interface
but one of them is marked as @primary it should be possible
to mock this interface.
Current implementation doesn't check if one of found beans is primary
and fails with an exception.
My change mirrors a similar logic used in spring-boot-starter-test
and resolves this issue.