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

Test methods without modifier are marked as unused #6557

Closed
Saljack opened this issue Oct 11, 2023 · 2 comments
Closed

Test methods without modifier are marked as unused #6557

Saljack opened this issue Oct 11, 2023 · 2 comments
Labels

Comments

@Saljack
Copy link

Saljack commented Oct 11, 2023

Description

JUnit 5 allows to use methods without any access modifier. Developers do not need to add public modifier and test classes are more readable. These test methods without any access modifier and with @Test annotation are marked in NetBeans as unused. This is not correct behaviour because these methods are used by the JUnit 5 runner.

import org.junit.jupiter.api.Test;

class TestClass {
  @Test
  void unusedTestMethod() { // <-- this is marked as unused
     // test code
  }

}

It would be really nice to remove this false positive warning or disable some hints only in test files.

Note:
There are multiple annotations which mark test methods e.g. @ParamatrizedTest so it should check if method has anywhere @Testable annotation.

Use case/motivation

The test classes contain many warnings and it is easy to overlook some meaningful warning/error.

Related issues

No response

Are you willing to submit a pull request?

No

@Saljack Saljack added kind:feature A feature request needs:triage Requires attention from one of the committers labels Oct 11, 2023
@mbien mbien added tests hints and removed needs:triage Requires attention from one of the committers labels Oct 13, 2023
@mbien
Copy link
Member

mbien commented Oct 13, 2023

this got likely fixed in NB 20 via #6277

@Saljack
Copy link
Author

Saljack commented Feb 23, 2024

Yes it is fixed

@Saljack Saljack closed this as completed Feb 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants