Unable to get Jacoco to work with Powermockito using offline instrumentation

前端 未结 12 1740
醉梦人生
醉梦人生 2020-12-13 01:56

Given that Jacoco doesn\'t play nicely with PowerMockito when instrumenting \"on the fly\", I\'ve been trying to configure offline instrumentation in the hope this will give

12条回答
  •  萌比男神i
    2020-12-13 02:30

    The report is correct. The provided test leads to no coverage as you mock what happens when calling the method "say". One should never mock the "instance/class under test", only do this for the dependencies and surroundings of the test subject.

    In this case: The code return "hello:"+s; is never reached by the test and the constructor of Utils is not called. There is no coverage displayed as there is no test coverage of these lines at all.

    Nevertheless using JaCoCo and PowerMock together is not trivial. I am currently looking for how to get it to run, too. Maybe your provided test is just unluckily written and JaCoCo is already working as it should?

提交回复
热议问题