Skip to content

Remove BDDMockito Checkstyle rule #34616

Closed
@sbrannen

Description

@sbrannen

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.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions