Add failing test for #4975

This commit is contained in:
Juan Martín Sotuyo Dodero
2024-04-26 16:00:03 -03:00
parent 11b8fa2f45
commit 905bb6518b

View File

@ -1901,6 +1901,40 @@ public class NotUsedPrivateMethodFalsePositive {
return clientIdsToDps.getUnchecked("");
}
}
]]></code>
</test-code>
<test-code>
<description>[java] UnusedPrivateMethod false positive when using @MethodSource on a @Nested test #4975</description>
<expected-problems>0</expected-problems>
<code><![CDATA[
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.params.provider.MethodSource;
import org.junit.jupiter.params.ParameterizedTest;
class FooTest{
@Nested
class ExampleTest {
@ParameterizedTest
@MethodSource("getStrings")
void exampleTestUsingPrivateMethod(
List<String> strings) {
// insert code
}
private static Stream<Arguments> getStrings() {
Stream<Arguments> tests = Stream.of(
Arguments.of(List.of("TEST", "TEST_1")),
Arguments.of(List.of("TEST_2", "TEST_3"))
);
return Stream.of(tests)
.reduce(Stream::concat)
.orElseGet(Stream::empty);
}
}
}
]]></code>
</test-code>
</test-data>