Rule S5979 use deprecated api of mockito

MockitoAnnotations.initMocks is now deprecated. New MockitoSession - mockito-core 3.8.0 javadoc can be used instead.

Link to documentation of *Mockito 2.x - which is old one.
There is new version 3.x - mockito-core 3.8.0 javadoc (org.mockito)

There is MockitoTestNGListener - mockito-testng 0.2.10 javadoc for TestNG

Maybe it is not a bug but improvement, I think that new rule should refer to the latest version of library.

Hello @slawekjaranowski,
Thanks for the report :slight_smile: Let’s address the issues in order:

  1. RSPEC-5979 supports both the deprecated initMocks and the newer openMocks. While I get the point about discouraging the use of deprecated APIs, IDEs and other sonar rules do a good job of signaling this. But maybe we can change the documentation rule so that initMocks does not benefit from the free publicity.
  2. MockitoSession is not currently supported by the rule but a ticket has been created to handle the issue
  3. Links are indeed pointing to outdated documentation and will be updated
  4. TestNG annotations are not currently covered by the rule but a ticket has been created to handle the issue

Cheers and thanks for the feedback.

Dorian

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.