- What language is this for? Java
- Which rule? java:S2187
- Why do you believe it’s a false-positive/false-negative? Because the class contains tests, they are just in a nested class for better code organization.
- Are you using
- SonarQube Cloud? Yes
- How can we reproduce the problem?
With this class:
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
class StringTest {
@Nested
@DisplayName("Char tests")
class CharTest {
@Test
void shouldGetCharAtPosition() {
String s = "Hello";
char c = s.charAt(1);
assertThat(c).isEqualTo('e');
}
}
}
A blocker issue is raised:
Possibly the same as described in: java:S2187 false positive for @Nested tests
This seems to be a regression, since support was added in 2018: Add support for @Nested test classes (JUnit5) by olcbean · Pull Request #1878 · SonarSource/sonar-java · GitHub