Hey SonarSource team
I think I found a false positive for the rule 5979 - Annotated Mockito objects should be initialized
The rule is raised on the declaration of my mock in this code
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.testng.MockitoTestNGListener;
@Listeners(MockitoTestNGListener.class)
public class TestClass {
@Mock
private MyMockedClass mockedClass;
@InjectMocks
private MyClassWithInjectdMocks myClass;
...
}
I believe that using the @Listeners(MockitoTestNGListener.class)
is the equivalent of @RunWith(MockitoJUnitRunner.class)
when using JUnit and this rule should not be raised here.
with
Xavier
PS: Iām using SonarLint for IntelliJ version 4.14.2.28348