You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "reswqa (via GitHub)" <gi...@apache.org> on 2023/04/13 17:27:47 UTC

[GitHub] [iceberg] reswqa commented on issue #7160: Move JUnit4 tests to JUnit5

reswqa commented on issue #7160:
URL: https://github.com/apache/iceberg/issues/7160#issuecomment-1507348739

   Hi guys,
   
   I am very happy to see this discussion on migrating test framework to `Junit5`, which will bring great benefits to the testing part of the project. For example, stronger support for parameterized test and better support for lambda expressions.
   
   Since the `Apache Flink` community has already started migrating tests to `Junit5` and `Assertj` a long time ago, maybe we can learn something from it. In short, It adopted a `module-by-module` migration solution, and you can refer to this umbrella [ticket](https://issues.apache.org/jira/browse/FLINK-25325)). 
   
   
   > It's worth looking at https://junit.org/junit5/docs/current/user-guide/#migrating-from-junit4.
   
   It is really a good reference to start. At the same time, I would like to share the [migration guidance]([JUnit5 migration guide](https://docs.google.com/document/d/1514Wa_aNB9bJUen4xm5uiuXOooOJTtXqS_Jqk9KJitU/edit)) of the flink community for your reference.
   
   
   > It's also worth mentioning that there are scripts available to convert assertions: https://assertj.github.io/doc/#assertj-migration
   This script does most of the boring migration stuff. However, according to my experience, there are still many situations that it cannot handle, such as converting `try{} catch(expected exception)` to `Assertions.assertThatThrowBy`. However, there are not many such exceptions. We can run this script first and spend a little more time to manually handle some special cases.
   
   > Things like @Rule public TemporaryFolder temp = new TemporaryFolder(); don't work in JUni5 and would have to be converted to @TempDir Path temp;.
   
   Yes, something like this does the more tedious part of the migration process. 
   `Juint5` has much better support for parameterized tests to avoid separating parameterized and non-parameterized parts into different test classes. But this also brings some troubles to our migration, because many of our previous tests were parameterized for the whole class, but now we have to inject parameters for each method.
   In order to avoid the inconvenience caused by the above problems as much as possible, we have done some work in flink:
   - Introduce `ParameterizedTestExtension` and some annotations to make it easier to migrate test class that require parameterization for all methods.
   - Introduce `TempDirUtils` to provide some common methods in `org.junit.rules.TemporaryFolder` but for `Junit5`.
   For more details, please refer to this [ticket](https://issues.apache.org/jira/browse/FLINK-25315).
   
   Of course, I am also very willing to participate in the migration of iceberg's test framework, and I look forward to taking this opportunity to integrate into this great community.
   
   
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org