0

我的 pom 文件中有以下内容:

pom.xml

<reporting>
    <plugins>
        <plugin>
            <groupId>org.pitest</groupId>
            <artifactId>pitest-maven</artifactId>
            <version>1.1.8</version>
            <configuration>
                <targetClasses>
                    <param>com.myService.utility.*</param>
                </targetClasses>
                <reportsDirectory>/my-service/target</reportsDirectory>
                <targetTests>
                    <param>com.myService.utility.util.*</param>
                </targetTests>
                <timeoutConstant>5000</timeoutConstant>
                <excludeClasses>
                    <param>com.myService.utility.EmailImpl.java</param>
                    <param>com.myService.utility.Email.java</param>
                    <param>com.myService.utility.ValidationUtil.java.java</param>
                </excludeClasses>
                <avoidCallsTo>
                    <avoidCallsTo>org.apache.log4j</avoidCallsTo>
                    <avoidCallsTo>org.slf4j</avoidCallsTo>
                    <avoidCallsTo>org.apache.commons.logging</avoidCallsTo>
                </avoidCallsTo>
            </configuration>
            <reportSets>
                <reportSet>
                    <reports>
                        <report>report</report>
                    </reports>
                </reportSet>
            </reportSets>
        </plugin>
    </plugins>
</reporting>

当我运行测试时,超时似乎没有从默认的 3000 改变,excludeClasses 中的类仍然被拾取,并且它仍然抱怨 log4j 的配置(虽然它是 log4j2 所以这看起来像是我的错指定)。我在 PITest 文档或其他任何地方都找不到很多示例,除了使用 targetClasses 和 targetTests 的非常简单的示例

编辑:我尝试将报告标签更改为构建标签并删除了 reportSets 部分。仍然没有变化;实用程序 src 包包含 6 个类,其中我在 pom 中概述的 3 个应排除在外,并且在 test 对应包中有 3 个测试文件。记者仍在拉入要排除的类,并显示为 0% 行和突变覆盖率。尽管具有 AvoidCallsTo 值,但它也抱怨 log4j 配置

4

1 回答 1

2

配置需要在 build/plugins 下提供,而不是报告。

不幸的是,当 maven 无法将 XML 映射到插件时,它不会抛出任何错误。

包含/排除的类接受针对 java 包的 glob - 不是源文件,所以应该看起来像:-

<excludeClasses>
    <param>com.myService.utility.EmailImpl</param>
    <param>com.myService.utility.Email</param>
    <param>com.myService.utility.ValidationUtil</param>
</excludeClasses>
于 2016-07-29T13:37:31.043 回答