[ 
https://issues.apache.org/jira/browse/HADOOP-14693?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17402174#comment-17402174
 ] 

Steve Loughran commented on HADOOP-14693:
-----------------------------------------

There's an IntelliJ article on the topic too
https://blog.jetbrains.com/idea/2020/08/migrating-from-junit-4-to-junit-5/

One big PITA is that the Assertion classes have changed. I think it's a real 
shame that this has changed as it is generating needless work. 

Similarly, @Ignore attributes now need to move to @Disabled. Again, I think 
this is "unfortunate"

Even with the automated migration and IDE support this is going to make back 
porting really painful. Normally all test suites which avoid Mockito go back to 
any of version without problems; now we (I!) are going to have to change them, 
recompile, and rerun.

I note that we have alternatives to some of the JUnit methods which will 
backport seamlessly

* AssertJ assertions
* {{ContractTestUtils.skip(message)}} over {{@Ignore}}
* LambdaTestUtils.intercept over @Expected (also, it provides better 
diagnostics with the toString() of what the l-expression was, etc etc.)


It's makes me think: can we enforce the use of those over the JUnit5 versions? 
Or at least have checkstyle recommending them.

AssertJ is a bit verbose for simple asserts, and I would not advocate replacing 
all existing assertTrue, assertEquals etc with them, but we could
# warn on new code with the classic JUnit asserts
# warn on @Disabled, @Expected
# reject hamcrest asserts entirely

Given that AssertJ and intercept are, IMO, better, we can justify this on test 
Qquality rather than just ease of back porting.


> Upgrade JUnit from 4 to 5
> -------------------------
>
>                 Key: HADOOP-14693
>                 URL: https://issues.apache.org/jira/browse/HADOOP-14693
>             Project: Hadoop Common
>          Issue Type: Improvement
>            Reporter: Akira Ajisaka
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 1.5h
>  Remaining Estimate: 0h
>
> JUnit 4 does not support Java 9. We need to upgrade this.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-issues-h...@hadoop.apache.org

Reply via email to