https://github.com/apache/netbeans/pull/6277

should be in NB 20.

-mbien

On 09.08.23 17:48, Ulrich Mayring wrote:
Netbeans generates an "Unused Element" hint in the sidebar and a wavy underline in the editor if I define a variable or method that goes unused. This is a very useful feature, but in the case of JUnit5 it has an unwanted effect. For example:

@Test
void myTest() { ... }

This method is recognized as an "Unused Element", although it's a Unit Test that will be called by the framework. I can add the "public" modifier to the method and the hint disappears, but then Sonar (and probably other static code analysis tools) flag this as non-compliant code. The reason is that in JUnit5 it is recommended to keep Unit Test methods package-private:

https://junit.org/junit5/docs/current/user-guide/#writing-tests-classes-and-methods

As far as I can see they give no compelling reason for that recommendation, but is there a compelling reason for Netbeans to flag package-private test methods as unused?

cheers,

Ulrich



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@netbeans.apache.org
For additional commands, e-mail: users-h...@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to