[Tests] Fix invalid test case in ProcessUtilsTest.testCancelApplication#6130
[Tests] Fix invalid test case in ProcessUtilsTest.testCancelApplication#6130zuston wants to merge 1 commit intoapache:devfrom
Conversation
Codecov Report
@@ Coverage Diff @@
## dev #6130 +/- ##
============================================
- Coverage 44.02% 42.83% -1.20%
+ Complexity 3701 3611 -90
============================================
Files 634 635 +1
Lines 26025 25910 -115
Branches 2917 2938 +21
============================================
- Hits 11457 11098 -359
- Misses 13467 13735 +268
+ Partials 1101 1077 -24
Continue to review full report at Codecov.
|
|
Kudos, SonarCloud Quality Gate passed! |
| public static HadoopUtils getInstanceForTest() { | ||
| return new HadoopUtils(false); | ||
| } | ||
|
|
There was a problem hiding this comment.
This approach is not recommended. just for the test.
There was a problem hiding this comment.
So directly using new HadoopUtils(false) ? Or other approach ?
There was a problem hiding this comment.
I prefer other ways. Or it is recommended to refactor it, and it is not recommended to use static code blocks in this case.
There was a problem hiding this comment.
Could you help give me some suggestions? Have no ideas on it. Thanks~
There was a problem hiding this comment.
An important factor in unit testing is structuring your code so that it is suitable for testing. code with excessive static initialization is not a structure that's easily tested. Even you can see that the famous Mockito does not support static method testing so far, my suggestion is You refactor the code and give up the use of static methods. this scenario is not applicable. we cannot use mocks to complete the mocks of external components.








Purpose of the pull request
Brief change log
Verify this pull request
This pull request is code cleanup without any test coverage.
(or)
This pull request is already covered by existing tests, such as (please describe tests).
(or)
This change added tests and can be verified as follows: