forked from phoedos/pmd
Add failing test for #4975
This commit is contained in:
@ -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>
|
||||
|
Reference in New Issue
Block a user