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

Complain when @Test is applied to an inappropriate method #1074

Closed
islandsvinur opened this issue Sep 25, 2017 · 2 comments
Closed

Complain when @Test is applied to an inappropriate method #1074

islandsvinur opened this issue Sep 25, 2017 · 2 comments

Comments

@islandsvinur
Copy link

islandsvinur commented Sep 25, 2017

Overview

When writing tests in Groovy, it's tempting to use def for the test methods, since that is typically the way to go in Groovy. However, for def the compiler produces a method that returns Object.

If this was a method annotated with @Test, it would be silently ignored by JUnit, as it should be a void method. This leads to lots of pulled hairs and other frustrations.

Test run finished after 13 ms
[         2 containers found      ]
[         0 containers skipped    ]
[         2 containers started    ]
[         0 containers aborted    ]
[         2 containers successful ]
[         0 containers failed     ]
[         0 tests found           ]
[         0 tests skipped         ]
[         0 tests started         ]
[         0 tests aborted         ]
[         0 tests successful      ]
[         0 tests failed          ]

I would like JUnit to shout in my face that I'm using it wrong.

@bechte
Copy link
Contributor

bechte commented Sep 25, 2017

Thanks for bringing up this issue.

We will have a look into it and provide a validation message that complains about the generated method or provide a fallback (and only printing a warning).

@sbrannen
Copy link
Member

Closing this issue since it is a duplicate of #242.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants