Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

False positive report of UnusedVariable for fields used with JUnit5 FieldSource annotation #4713

Open
genericjon opened this issue Dec 4, 2024 · 0 comments

Comments

@genericjon
Copy link

A variable that is used by JUnit5's FieldSource annotation will be flagged as an unused variable. The FieldSource annotation was introduced in JUnit version 5.11.

Example:

class FieldSourceTest {
    private static final List<String> fooParameters = List.of("apple", "banana");

    @ParameterizedTest
    @FieldSource("fooParameters")
    public void foo(String bar) {
        System.out.println(bar);
    }
}

Output:

FieldSourceTest.java:2: error: [UnusedVariable] The field 'fooParameters' is never read.

This is similar to #2335, where methods used by MethodSource were flagged as unused.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant