When using TestParameterInjector, parameterizing a test method parameter with
@TestParameter and only a single input value adds test runner and annotation
overhead without testing multiple cases. Instead, declare a local variable
initialized to that value inside the test method. This also avoids parsing
values from strings at runtime and, for enums, replaces string literals with
direct symbol references so cross-references and refactoring tools work
properly.
@Test
public void someTest(
@TestParameter("RED") Color color,
@TestParameter boolean enabled) {
...
}
@Test
public void someTest(@TestParameter boolean enabled) {
Color color = Color.RED;
...
}
Suppress false positives by adding the suppression annotation @SuppressWarnings("SingleValueTestParameter") to the enclosing element.