You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If a given Cucumber Java project uses CheckStyle, one of the warnings raised is the IllegalThrowsCheck for Step Definitions, because, by default, they throw a Throwable.
Expected Behaviour
We could try to improve the default throws of step definitions to ensure that types (Like Error or Throwable) are not declared to be thrown and are not allowed.
Current Behavior
The current behaviour is that by default, we allow throwing Throwables.
Context & Motivation
Like mentioned above, if a given Cucumber Java project uses CheckStyle and depends on its validations, a common failure is the throwing of Throwables.
The text was updated successfully, but these errors were encountered:
It is not required for a step definition to declare any exceptions. You can remove these or reduce their severity to satisfy your check style.
We can't disallow step definitions from throwing Throwable or declaring it as thrown but I am I'm assuming that you are using an IDE plugin which uses the SnippetGenerator to create your step definitions. By default the JavaSnippet declares Throwable in its template which is indeed more then it needs to be. Exception should be sufficient.
This should reduce the manual labor of fixing generated code somewhat.
Tests are allowed to fail by throwing an(y) exception. As such #318
added `throws Throwable` to the JavaSnippet. Aside from being a bad
practice this results in unnecessary checkstyle warnings. As such the
generated snippet should not explicitly declare `Throwable`.
Reducing `Throwable` to `Exception` should be sufficient.
Fixes#1207
Summary
If a given Cucumber Java project uses CheckStyle, one of the warnings raised is the
IllegalThrowsCheck
for Step Definitions, because, by default, they throw a Throwable.Expected Behaviour
We could try to improve the default throws of step definitions to ensure that types (Like Error or Throwable) are not declared to be thrown and are not allowed.
Current Behavior
The current behaviour is that by default, we allow throwing Throwables.
Context & Motivation
Like mentioned above, if a given Cucumber Java project uses CheckStyle and depends on its validations, a common failure is the throwing of Throwables.
The text was updated successfully, but these errors were encountered: