[ https://issues.apache.org/jira/browse/SCXML-284?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16645388#comment-16645388 ]
ASF GitHub Bot commented on SCXML-284: -------------------------------------- GitHub user mureinik opened a pull request: https://github.com/apache/commons-scxml/pull/4 SCXML-284 Clean up exception handling in tests This PR cleans up the handling of exceptions in the test code: 1. The cumbersome idiom of `try`-`catch` with a `fail` call in the `try` block and additional assertions in the `catch` block were replaced with Jupiter's elegant `Assertions#assertThrows` call. 2. Redudant `throws` clauses were removed 3. `Issue112Test#test01issue112`'s code was cleaned up so it actually fails if an exception is thrown instead of catching it and printing it to `System.err`. You can merge this pull request into a Git repository by running: $ git pull https://github.com/mureinik/commons-scxml test-exceptions Alternatively you can review and apply these changes as the patch at: https://github.com/apache/commons-scxml/pull/4.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #4 ---- commit a59d8f1b4504e30b36c7a22ef2e087cbd98a7553 Author: Allon Mureinik <allon@...> Date: 2018-10-10T16:38:30Z SCXML-284 Issue112Test#test01issue112 catch In case an event can't be fired, something is wrong, and the test should fail, not catch and ignore the exception. commit 6c5932ac952a1b3d335fa7217f3b54799321dd95 Author: Allon Mureinik <allon@...> Date: 2018-10-10T16:45:44Z SCXML-284 Replace try-catch with assertThrows Use JUnit Jupiter's new mechanism of assertThrows instead of try-catch blocks in order to clean up the code and make it easier to follow. Since the questionable piece of code is now run inside a lambda and is caught by asserThrows itself, there's no need to declare these exceptions in the throws clause of the mehod declarations, and they were cleaned up to avoid adding compiler warnings. commit b2b670f8b8e0ff1a673d692be2ea38cb5fc54e66 Author: Allon Mureinik <allon@...> Date: 2018-10-10T16:50:17Z SCXML-284 Remove redundant throws declarations in tests ---- > Clear up exception handling in tests > ------------------------------------ > > Key: SCXML-284 > URL: https://issues.apache.org/jira/browse/SCXML-284 > Project: Commons SCXML > Issue Type: Task > Reporter: Allon Mureinik > Priority: Minor > > Following SCXML-283, JUnit Jupiter provides some tools to handle exception > testing in a more elegant way than catching an exception and asserting its > properties in that block -- This message was sent by Atlassian JIRA (v7.6.3#76005)