【问题标题】:PIT testing - need to exclude certain packages from the reportPIT 测试 - 需要从报告中排除某些包
【发布时间】:2018-09-27 08:14:33
【问题描述】:

我正在尝试生成 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.* 包和 test.service.impl.AuthenticationServiceImpl.userAuthentication 方法的覆盖率。

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

【问题讨论】:

    标签: code-coverage mutation pitest


    【解决方案1】:

    您应该能够将 test.security.* 从突变中排除

    <excludedClasses>
     <param>test.security.*</param>
    </excludedClasses>
    

    您在 AvoidCallsTo 中的条目将防止对 test.security 中的方法进行调用的其他包中的代码行发生突变。*

    【讨论】:

    • 是否递归地排除了 test.security 包中的所有类?我正在寻找一种方法来排除包层次结构下的所有类 - 以便排除 test.securitytest.security.util 下的所有类。
    • @Pat 是的,如果您在末尾包含通配符,它​​应该排除所有子包。这只是名称上的简单全局匹配。
    猜你喜欢
    • 2018-07-06
    • 2012-12-28
    • 2015-03-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-29
    • 2013-11-07
    • 2017-07-26
    相关资源
    最近更新 更多