-
-
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
Improve error message if multiple "test" annotations are present on a method #876
Comments
Agreed, there should definitely be a better error message. |
Note that this is likely a more general topic involving all types of "test" annotations such as Keep in mind that I have therefore changed this issue's title accordingly. |
BTW I've wrote inspections for IntelliJ to highlight such dbl tests. |
Nice, @akozlova! 👍 |
@akozlova, in IntelliJ do you simply inspect for multiple annotations meta-annotated with Or do you check for individual "test" annotations? |
Now it's only check for predefined annotations, mainly due to the fact that IDEA knows nothing about custom engines and thus can't check them: who knows, probably some engine would require both parameterized and some testable annotation due to the fact that jupiter won't be available/filtered. |
Makes sense!
Yeah, I was pondering the exact same thing. 😉 |
I accidentally ended up with |
in progress |
Update: In my local branch, JUnit Jupiter now logs the following warning in such cases.
How does that sound? |
Note that, with the aforementioned log statement, the test would still fail in the same manner as described in this issue's description, but the warning would help to determine the cause. |
SGTM! 👍 |
Prior to this commit, the execution of a test method could fail with a misleading exception message if the method was annotated with more than one "test" annotation -- for example, with @test and @ParameterizedTest. This commit addresses this issue by logging a warning if more than one TestDescriptor is resolved for a single method. This helps to debug errors resulting from a method being simultaneously annotated with multiple competing annotations such as @test, @RepeatedTest, @ParameterizedTest, @testfactory, etc. Issue: #876
Resolved in |
Good! |
For the following test two descriptors will be created -- one for
@ParameterizedTest
and another for@Test
:The parameterized test passes, while the other one fails because JUnit Juiter cannot resolve the parameter:
I don't know if it's a bug or a feature, but because I didn't know about this I spent an hour debugging JUnit. I assume many more people could step on this, so would be great to make the logic more obvious. Couple of options:
@Test
if some other test descriptor is created... This can happen e.g. if 2 different Test annotations are put on one method.
boolean supportsTest(...)
Related Issues
The text was updated successfully, but these errors were encountered: