dolphinscheduler
dolphinscheduler copied to clipboard
[Improvement][UT] Upgrade junit to 5.+
Search before asking
- [X] I had searched in the issues and found no similar feature requirement.
Description
Right now, we still use junit 4.+ in our repo, I hope we can upgrade to Junit 5.+, then we can easy to write the UT, JUnit 5 provide some useful feature, e.g. assertThrow
, assertTimeout
...
Are you willing to submit a PR?
- [ ] Yes I am willing to submit a PR!
Code of Conduct
- [X] I agree to follow this project's Code of Conduct
cc #10573
Thank you for your feedback, we have received your issue, Please wait patiently for a reply.
- In order for us to understand your request as soon as possible, please provide detailed information、version or pictures.
- If you haven't received a reply for a long time, you can join our slack and send your question to channel
#troubleshooting
What about using TestNG
?
What about using
TestNG
?
This may need to refactor all test code, if we want to use TestNG
to replace Junit
What about using
TestNG
?This may need to refactor all test code, if we want to use
TestNG
to replace Junit
@ruanwenjun Yes. At this moment, I think we have about 4 people, me and my colleagues who will work on the UT refactoring. It is possible for us to refactor all test code and fix all related style / formatting issues. The question lying between choosing TestNG
and jUnit
is whether it is necessary to replace one with another. So far, I've found some advantages of TestNG
over jUnit
:
-
TestNG
supports running UT in parallelism. -
TestNG
supportstesting group
. -
TestNG
supports an easier way to pass data into testing method usingData Provider
. -
TestNG
supportsDependency Test
. -
TestNG
supportsParameterization
throughxml
configuration.
Some related materials:
- https://www.youtube.com/watch?v=OWXWQE4pL_0
- https://www.guru99.com/junit-vs-testng.html
Although TestNG
is more powerful, it seems that it is not a must
to switch jUnit
to TestNG
🤣
WDYT?
What about using
TestNG
?This may need to refactor all test code, if we want to use
TestNG
to replace Junit@ruanwenjun Yes. At this moment, I think we have about 4 people, me and my colleagues who will work on the UT refactoring. It is possible for us to refactor all test code and fix all related style / formatting issues. The question lying between choosing
TestNG
andjUnit
is whether it is necessary to replace one with another. So far, I've found some advantages ofTestNG
overjUnit
:
TestNG
supports running UT in parallelism.TestNG
supportstesting group
.TestNG
supports an easier way to pass data into testing method usingData Provider
.TestNG
supportsDependency Test
.TestNG
supportsParameterization
throughxml
configuration.Some related materials:
- https://www.youtube.com/watch?v=OWXWQE4pL_0
- https://www.guru99.com/junit-vs-testng.html
Although
TestNG
is more powerful, it seems that it is not amust
to switchjUnit
toTestNG
🤣WDYT?
If we choose not to switch jUnit
to TestNG
, I support upgrading jUnit
to 5.+
What about using
TestNG
?This may need to refactor all test code, if we want to use
TestNG
to replace Junit@ruanwenjun Yes. At this moment, I think we have about 4 people, me and my colleagues who will work on the UT refactoring. It is possible for us to refactor all test code and fix all related style / formatting issues. The question lying between choosing
TestNG
andjUnit
is whether it is necessary to replace one with another. So far, I've found some advantages ofTestNG
overjUnit
:
TestNG
supports running UT in parallelism.TestNG
supportstesting group
.TestNG
supports an easier way to pass data into testing method usingData Provider
.TestNG
supportsDependency Test
.TestNG
supportsParameterization
throughxml
configuration.Some related materials:
- https://www.youtube.com/watch?v=OWXWQE4pL_0
- https://www.guru99.com/junit-vs-testng.html
Although
TestNG
is more powerful, it seems that it is not amust
to switchjUnit
toTestNG
🤣WDYT?
AFAIK, Junit5+ can support these features.
What about using
TestNG
?This may need to refactor all test code, if we want to use
TestNG
to replace Junit@ruanwenjun Yes. At this moment, I think we have about 4 people, me and my colleagues who will work on the UT refactoring. It is possible for us to refactor all test code and fix all related style / formatting issues. The question lying between choosing
TestNG
andjUnit
is whether it is necessary to replace one with another. So far, I've found some advantages ofTestNG
overjUnit
:
TestNG
supports running UT in parallelism.TestNG
supportstesting group
.TestNG
supports an easier way to pass data into testing method usingData Provider
.TestNG
supportsDependency Test
.TestNG
supportsParameterization
throughxml
configuration.Some related materials:
- https://www.youtube.com/watch?v=OWXWQE4pL_0
- https://www.guru99.com/junit-vs-testng.html
Although
TestNG
is more powerful, it seems that it is not amust
to switchjUnit
toTestNG
🤣 WDYT?AFAIK, Junit5+ can support these features.
@ruanwenjun Sounds good to me. I will take this issue.
I found a post about differences between jUnit4
and jUnit5
, as well as how to migrate: https://blogs.oracle.com/javamagazine/post/migrating-from-junit-4-to-junit-5-important-differences-and-benefits
Great! It seems use Junit5+ can achieve the same with less change.
I'm working on this, will submit a PR tomorrow or next week.
In DolphinScheduler, we sometimes use Powermock
for UTs. However, it seems Powermock
does not and will not support jUnit 5. https://github.com/powermock/powermock/issues/929
In DolphinScheduler, we sometimes use
Powermock
for UTs. However, it seemsPowermock
does not and will not support jUnit 5. powermock/powermock#929
Can we use Mokito to replace powermock?
In DolphinScheduler, we sometimes use
Powermock
for UTs. However, it seemsPowermock
does not and will not support jUnit 5. powermock/powermock#929Can we use Mokito to replace powermock?
Seems powermock
helps mock the static
, private
and final
methods more easily. Anyway I will look into it and see whether there is a way to use mockito
to replace powermock
.
In DolphinScheduler, we sometimes use
Powermock
for UTs. However, it seemsPowermock
does not and will not support jUnit 5. powermock/powermock#929Can we use Mokito to replace powermock?
Seems
powermock
helps mock thestatic
,private
andfinal
methods more easily. Anyway I will look into it and see whether there is a way to usemockito
to replacepowermock
.
If we can find the alternative or the method to do it, we can get rid of it