PowerMock ECLEmma coverage issue

前端 未结 8 1807
无人共我
无人共我 2020-11-30 09:39


We are using EasyMock and PowerMock with JUnit. The coverage tool used is ECLEmma. With EasyMock, it shows the coverage properly in green (as covered). However, for

8条回答
  •  长情又很酷
    2020-11-30 10:13

    I have managed to generate PowerMock coverage with Jacoco, using powermock-module-javaagent.

    Just make sure you put powermock agent after jacoco agent:

    maven-surefire-plugin
                
                    true
                    ${jacocoArgLine} -javaagent:${settings.localRepository}/org/powermock/powermock-module-javaagent/${powermock.version}/powermock-module-javaagent-${powermock.version}.jar -noverify
    ...
    

    If you want to see an example, take a look at this project: https://github.com/jfcorugedo/sonar-scanner

    Here you can see that sonar takes into account static methods and new statements mocked by PowerMock:

    If you want to mock newstatements make sure you use PowerMockRule instead of PowerMockRunner.

    Take a look at this test

提交回复
热议问题