Skip to content
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

Remove BDDMockito Checkstyle rule #34616

Closed
sbrannen opened this issue Mar 18, 2025 · 0 comments
Closed

Remove BDDMockito Checkstyle rule #34616

sbrannen opened this issue Mar 18, 2025 · 0 comments
Assignees
Labels
type: task A general task
Milestone

Comments

@sbrannen
Copy link
Member

Although we have a Checkstyle rule which attempts to enforce the use of BDDMockito...

<module name="com.puppycrawl.tools.checkstyle.checks.regexp.RegexpSinglelineJavaCheck">
<property name="id" value="bddMockito"/>
<property name="maximum" value="0"/>
<property name="format" value="org\.mockito\.Mockito\.(when|doThrow|doAnswer)"/>
<property name="message" value="Please use BDDMockito."/>
<property name="ignoreComments" value="true"/>
</module>

... that rule does not actually enforce anything.

For example, it's still possible to statically import methods declared in Mockito via BDDMockito, and that has happened numerous times across the code base.

import static org.mockito.BDDMockito.doThrow;
import static org.mockito.BDDMockito.mock;
import static org.mockito.BDDMockito.times;
import static org.mockito.BDDMockito.verify;
import static org.mockito.BDDMockito.when;
import static org.mockito.BDDMockito.willAnswer;

During a team discussion, we decided that the team currently has no preference regarding BDDMockito stubbing APIs over traditional Mockito stubbing APIs. In addition, certain IDEs (for example, Eclipse) covert static imports for org.mockito.BDDMockito.when to org.mockito.Mockito.when which then fails the Gradle build even though the latter import is technically more correct.

In light of that, we have decided to simply remove the BDDMockito Checkstyle rule.

@sbrannen sbrannen added the type: task A general task label Mar 18, 2025
@sbrannen sbrannen added this to the 6.2.5 milestone Mar 18, 2025
@sbrannen sbrannen self-assigned this Mar 18, 2025
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

No branches or pull requests

1 participant