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&nbsp;powermock and jacoco, see
at&nbsp;https://github.com/powermock/powermock/issues/727.&nbsp;so&nbsp;
if you use&nbsp;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&gt;.


Mockito works well with jacoco, So I suggest use&nbsp;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:
&gt; There is nothing preventing me from using&nbsp;final,&nbsp;new, or&nbsp;static...&nbsp;
&gt; but it is my&nbsp;Opinion&nbsp;that code in such methods shouldn't require mocking&nbsp;
&gt; if I choose to use them. If they are that complex or riddled with side effects,
&gt; I probably should think about encapsulating into other objects so I could inject&nbsp;
&gt; mocks at test time or when implementations change.&nbsp;