1

我尝试运行“mvn clean test”来获得我的测试的突变覆盖率,但它找不到任何东西。我使用了很多不同的设置,但我找不到解决方案。我的设置可能有误吗?

Pom.xml

<build>
    <plugins>

        <plugin>
            <groupId>org.pitest</groupId>
            <artifactId>pitest-maven</artifactId>
            <version>1.4.5</version>
            <executions>
                <execution>
                    <id>pitest-mutation-coverage</id>
                    <phase>test</phase>
                    <goals>
                        <goal>mutationCoverage</goal>
                    </goals>

                </execution>
            </executions>
            <dependencies>
                <dependency>
                    <groupId>org.pitest</groupId>
                    <artifactId>pitest-junit5-plugin</artifactId>
                    <version>0.8</version>
                </dependency>
            </dependencies>
            <configuration>
                <targetClasses>
                    <param>at.my.swtesting.*</param>
                </targetClasses>
                <targetTests>
                    <param>at.my.swtesting.*</param>
                </targetTests>    
            </configuration>
        </plugin>

    </plugins>
</build>

重要的日志消息:

08:14:47 PIT >> INFO : Verbose logging is disabled. If you encounter a problem, please enable it before reporting an issue.
08:14:47 PIT >> INFO : Sending 4 test classes to minion
08:14:47 PIT >> INFO : Sent tests to minion
08:14:47 PIT >> INFO : MINION : 08:14:47 PIT >> INFO : Checking environment

08:14:48 PIT >> INFO : MINION : 08:14:48 PIT >> INFO : Found  0 tests

08:14:48 PIT >> INFO : MINION : 08:14:48 PIT >> INFO : Dependency analysis reduced number of potential tests by 0

08:14:48 PIT >> INFO : MINION : 08:14:48 PIT >> INFO : 0 tests received

08:14:48 PIT >> INFO : Calculated coverage in 0 seconds.
08:14:48 PIT >> INFO : Created  0 mutation test units

[ERROR] Failed to execute goal org.pitest:pitest-maven:1.4.5:mutationCoverage (pitest-mutation-coverage) on project exercise01-assignment01: Execution pitest-mutation-coverage of goal org.pitest:pitest-maven:1.4.5:mutationCoverage failed: No mutations found. This probably means there is an issue with either the supplied classpath or filters.
4

1 回答 1

0

您已将“at.my.swtesting.*”配置为目标类,因此pit 将尝试改变“swtesting”包内的类。

确保源类存在于“swtesting”包中,以便pit 可以找到它们并改变代码。

只需添加一个演示类和方法。在方法中做一些添加并打印输出。

如果提供的类路径正常,则应生成突变报告。

运行pit时,还会生成'pitClasspath'文件,其中列出了pit类路径中的所有文件。也检查一下。

于 2022-01-04T09:37:49.997 回答