The core methods of Mockito are called through the class name, where static imports make stubbing and verification read as sentences
What it finds
Mockito is designed to read as when(repo.find(1)).thenReturn(user) and verify(repo).save(user). Mockito.when and Mockito.verify repeat the class name in every line of a test.
Reported is a call of when, verify, mock, spy, doReturn, doThrow or doNothing on Mockito.
From the rule's source, qualified_mockito_call.rs.
import org.mockito.Mockito; class StubTest { void run() { Repo repo = Mockito.mock(Repo.class);tx0 reports: static import Mockito.verify(repo).child();tx0 reports: static import } interface Repo { Repo child(); }} Turn it on, off or suppress it
The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/java:qualified-mockito-call" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/java:qualified-mockito-call] reason="..."tx0 explain tx0/java:qualified-mockito-call shows the same in the terminal. Found a false positive? Report it.