PIT测试 - 需要从报告中排除某些包

时间:2018-04-17 11:23:59

标签: code-coverage mutation pitest

我正在尝试生成PIT测试覆盖率报告,我需要排除某个包。 这些是使用的配置:

<plugin>
                        <groupId>org.pitest</groupId>
                        <artifactId>pitest-maven</artifactId>
                        <version>1.3.0</version>
                        <configuration>
                            <targetClasses>
                                <param>test.presentation.*</param>
                                <param>test.service.impl.*</param>
                            </targetClasses>
                            <targetTests>
                                <param>test.App.ServletInitializerTest</param>
                                <param>test.presentation.AuthenticationControllerTest</param>
                                <param>test.service.impl.AuthenticationServiceImplTest</param>
                            </targetTests>
                            <excludedClasses>
                                <param>test.security.AuthenticationSecurityServiceImpl</param>
                                <param>test.security.TokenAuthenticationFilter</param>
                                <param>test.security.TokenInfo</param>
                                <param>test.security.TokenManagerImpl</param>
                            </excludedClasses>
                            <excludedTestClasses>
                                <param>test.security.AuthenticationSecurityServiceImplTest</param>
                            </excludedTestClasses>
                            <excludedMethods>
                            <param>test.service.impl.AuthenticationServiceImpl.userAuthentication</param>
                            </excludedMethods>
                            <avoidCallsTo>
                            <avoidCallsTo>test.service.impl.AuthenticationServiceImpl</avoidCallsTo>
                            <avoidCallsTo>test.security.*</avoidCallsTo>
                            </avoidCallsTo>
                        </configuration>
                    </plugin>

但是我的报告仍然显示了test.security。* package和test.service.impl.AuthenticationServiceImpl.userAuthentication方法的覆盖范围。

如何在覆盖率报告中跳过此包和方法?

1 个答案:

答案 0 :(得分:0)

您应该能够使用

从变异中排除test.security。*
<excludedClasses>
 <param>test.security.*</param>
</excludedClasses>

您在avoidCallsTo中的条目将阻止突变到其他包中调用test.security中的方法的代码行。*