You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@dolphinscheduler.apache.org by Jave-Chen <ke...@foxmail.com> on 2020/02/11 04:21:03 UTC
[UT][MOCK] Sonarcloud analysis coverage 0 for unit test use powermock
Hi, allSince there is an issue with powermock and jacoco, see
at https://github.com/powermock/powermock/issues/727. so
if you use powermock with unit test , Sonarcloud will not
get the right coverage. You can read more at PR #1916
<https://github.com/apache/incubator-dolphinscheduler/pull/1916>.
Mockito works well with jacoco, So I suggest use Mockito
use as much as possible.
Further more, there are some discuss about PowerMock VS
Mockito, as:
https://stackoverflow.com/questions/6036450/powermock-mockito-vs-mockito-alone
https://stackoverflow.com/questions/5920153/test-class-with-a-new-call-in-it-with-mockito
And I support this opinion:
> There is nothing preventing me from using final, new, or static...
> but it is my Opinion that code in such methods shouldn't require mocking
> if I choose to use them. If they are that complex or riddled with side effects,
> I probably should think about encapsulating into other objects so I could inject
> mocks at test time or when implementations change.