-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Feature suggestion: Detect missing @Nested annotations #1736
Comments
@ivoanjo Thanks for providing such a detailed use case description. That's very helpful! This is definitely something that JUnit should validate at some point. For the time being, I think you could implement the validation yourself by implementing a custom extension and registering it globally. Would you be interested in giving that a try? |
That would unfortunately only work when such an extension is invoked for an enclosing test class that has testable methods. Otherwise, if the enclosing class is not registered as a test class itself, a custom extension would never be invoked. The issue here is that the validation we have in place is executed during the discovery phase, and if the validation (i.e., our |
Thanks @marcphilipp and @sbrannen for the feedback.
I don't have enough bandwidth to pick this up on my free time in the next few months, sorry! Hopefully some brave soul can help out in the meanwhile 🙂 |
This issue has been automatically marked as stale because it has not had recent activity. Given the limited bandwidth of the team, it will be automatically closed if no further activity occurs. Thank you for your contribution. |
Would still be nice to have this! |
This issue has been automatically marked as stale because it has not had recent activity. Given the limited bandwidth of the team, it will be automatically closed if no further activity occurs. Thank you for your contribution. |
Would still be nice to have this! |
This seems like an interesting feature, I would spend some time on it, if the team makes a decision on it. |
Hello there, and thanks for JUnit! 👋
My team has recently migrated to JUnit 5, and previously we were previously using the junit-hierarchicalcontextrunner for nested tests.
One big difference from that one is that on JUnit 5 the native nested tests require that nested classes be annotated with the
@Nested
annotation.We've now been using it for a few weeks, and my team found that sometimes we forget to add an
@Nested
annotation to an inner class.This leads to a test suite that is apparently green, but that in reality is missing tests, and is hard to spot.
Would it be possible to either:
add a validation that would warn us that we could possibly be missing
@Nested
-- by for instance detecting that a nested class had JUnit annotations on it but would not be executedhave a mode/option/top-level annotation for executing tests in nested classes without needing an explicit
@Nested
Thanks! 🙏
Related issues
The text was updated successfully, but these errors were encountered: