Skip to content

Conversation

@quaff
Copy link
Contributor

@quaff quaff commented Dec 28, 2021

  1. Replace Mockito.verify*() with BDDMockito.then()
  2. Replace Mockito.doReturn() with BDDMockito.willReturn()
  3. Adjust checkstyle rule

@quaff quaff force-pushed the patch-13 branch 5 times, most recently from 608fe73 to 8e313d0 Compare December 28, 2021 03:50
Copy link
Member

@snicoll snicoll left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR but I don't see a reason to change calls to verify.

@snicoll snicoll added status: waiting-for-feedback We need additional information before we can continue status: waiting-for-triage An issue we've not yet triaged labels Dec 28, 2021
@quaff
Copy link
Contributor Author

quaff commented Dec 29, 2021

Mixing given and verify is not elegant, pure BDD-style is better for readability.

<module name="com.puppycrawl.tools.checkstyle.checks.regexp.RegexpSinglelineJavaCheck">
<property name="maximum" value="0"/>
<property name="format" value="org\.mockito\.(Mockito|BDDMockito)\.(when|doThrow|doAnswer)" />
<property name="message"
value="Please use BDD-style (given, when, then) using BDDMockito imports." />
<property name="ignoreComments" value="true" />
</module>

Please use BDD-style (given, when, then) using BDDMockito imports.

@snicoll
Copy link
Member

snicoll commented Dec 29, 2021

@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.

@quaff
Copy link
Contributor Author

quaff commented Dec 30, 2021

@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.

@vpavic
Copy link
Contributor

vpavic commented Dec 30, 2021

@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.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Jan 4, 2022
@wilkinsona wilkinsona added the for: team-meeting An issue we'd like to discuss as a team to make progress label Jan 4, 2022
@philwebb philwebb added type: task A general task and removed status: waiting-for-triage An issue we've not yet triaged status: feedback-provided Feedback has been provided for: team-meeting An issue we'd like to discuss as a team to make progress labels Jan 12, 2022
@philwebb philwebb added this to the 2.5.x milestone Jan 12, 2022
@snicoll
Copy link
Member

snicoll commented Jan 13, 2022

Thanks both. We've discussed this as a team and decided to harmonize and use then rather than verify.

1. Replace Mockito.verify*() with BDDMockito.then()
2. Replace Mockito.doReturn() with BDDMockito.willReturn()
3. Adjust checkstyle rule
@snicoll snicoll self-assigned this Feb 1, 2022
@snicoll snicoll modified the milestones: 2.5.x, 2.5.10 Feb 1, 2022
snicoll pushed a commit that referenced this pull request Feb 1, 2022
1. Replace Mockito.verify*() with BDDMockito.then()
2. Replace Mockito.doReturn() with BDDMockito.willReturn()
3. Adjust checkstyle rule

See gh-29178
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: task A general task

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants