- Replace
Mockito.verify*()
withBDDMockito.then()
- Replace
Mockito.doReturn()
withBDDMockito.willReturn()
- Adjust checkstyle rule
Comment From: quaff
Mixing given
and verify
is not elegant, pure BDD-style is better for readability.
https://github.com/spring-projects/spring-boot/blob/47516b50c39bd6ea924a1f6720ce6d4a71088651/src/checkstyle/checkstyle.xml#L49-L55
Please use BDD-style (given, when, then) using BDDMockito imports.
Comment From: snicoll
@quaff that's a team decision I am afraid and what you've quoted doesn't include verify
on purpose, it states:
Please use BDD-style (given, when, then) using BDDMockito imports.
We've been there before and we have no intention to change calls to verify
at this point. If you revert that part, we can continue reviewing this PR.
Comment From: quaff
@quaff that's a team decision I am afraid and what you've quoted doesn't include
verify
on purpose, it states:Please use BDD-style (given, when, then) using BDDMockito imports.
We've been there before and we have no intention to change calls to
verify
at this point. If you revert that part, we can continue reviewing this PR.
Does the team decide to keep weird given
and verify
usage? I will create another PR to
remove unnecessary explicit Mockito.times(1)
if the answer is YES.
Comment From: vpavic
@snicoll What @quaff is trying to say is that Please use BDD-style (given, when, then) using BDDMockito imports message on the Checkstyle rule is actually in conflict with what you describe as the team's preference - you don't actually use BDDMockito#then
(as message the suggests) but rather Mockito#verify
.
FWIW I also find this mixed usage of BDD-style and traditional Mockito APIs to be rather confusing and unintuitive.
Comment From: snicoll
Thanks both. We've discussed this as a team and decided to harmonize and use then
rather than verify
.