- Sonar Qube 8.7.1 - developer edition
We are using a meta-annotation for setting up our tests which looks like this
@Tag("it")
@ActiveProfiles("it")
@ExtendWith(SpringExtension.class)
@ExtendWith(MockitoExtension.class)
@Retention(RetentionPolicy.RUNTIME)
public @interface SetupItTest
{
}
Now applying this annotation on a test class like
@SetupItTest
class UserControllerTest {
@Captor
private ArgumentCaptor<String> someCaptor;
}
The rule java:S5979
will trigger because it does not parse the meta annotation and does not “see” that the class is actually annotated with @ExtendWith(MockitoExtension.class)
through that annotation.
If I lift the annotation up on the test class like this, sonar will stop complaining
@ExtendWith(MockitoExtension.class)
@SetupItTest
class UserControllerTest {
@Captor
private ArgumentCaptor<String> someCaptor;
}
This happens since our upgrade to 8.7.0 since the rule java:S5979
was introduced there