在尝试运行PIT突变测试时,我收到以下错误:
mutationCoverage failed:计算线覆盖时,所有测试都没有通过而没有突变.变异测试需要绿色套件.
当我进行正常的测试构建时,测试运行得很好但是在运行突变测试阶段时,他们认为会失败,但没有提供有关原因的详细信息.我已经解决了PIT测试常见问题解答中列出的原因,但我仍然不知道可能出现的问题.
我试过了:
我还应该尝试一些其他的事情吗?或者其他方法来调试可能发生的事情?
我有以下内容:
public class UnsetProperty extends Command {
@Resource
private SetProperty setProperty;
public String parse(String[] args) {
if (args.length != 4) {
throw new RuntimeException("Incorrect number of arguments. Expected 4. Got " + args.length);
}
String publisher = args[0];
String version = args[1];
String mode = args[2];
String property = args[3];
/*
* Unsetting a property is done by changing the current property to null.
* Technically, the old property doesn't get changed, a new one is inserted with
* a …
Run Code Online (Sandbox Code Playgroud) 运行时mvn org.pitest:pitest-maven:mutationCoverage
出现如下错误(
Environment: Windows 10, Maven 3.6.1, Java 11, junit-jupiter 5.4.1, pitest 1.4.7
)
[ERROR] Failed to execute goal org.pitest:pitest-maven:1.4.7:mutationCoverage (default-cli) on project hello-strange-world: Execution default-cli of goal org.pitest:pitest-maven:1.4.7:mutationCoverage failed: Coverage generation minion exited abnormally. Please check the classpath.
[ERROR]
[ERROR] Please copy and paste the information and the complete stacktrace below when reporting an issue
[ERROR] VM : Java HotSpot(TM) 64-Bit Server VM
[ERROR] Vendor : Oracle Corporation
[ERROR] Version : 11.0.2+9-LTS
[ERROR] Uptime : 4936
[ERROR] …
Run Code Online (Sandbox Code Playgroud) 我想生成突变测试覆盖率.我在PI Test上做POC,但它没有参加我的测试课程而且失败了.我在pom.xml中配置了PTTest插件.我在pom.xml文件中检查了目标类包名称和目标测试类包名称是否正确.
我收到以下错误 -
10:50:29 AM PIT >> INFO : Mutating from D:\IR\workspace\cleanup_trunk\reporterDx-service\target\classes
10:50:29 AM PIT >> INFO : Verbose logging is disabled. If you encounter an problem please enable it before reporting an issue.
10:50:30 AM PIT >> INFO : Sending 0 test classes to slave
10:50:30 AM PIT >> INFO : Sent tests to slave
10:50:30 AM PIT >> INFO : Calculated coverage in 0 seconds.
10:50:30 AM PIT >> INFO : Created 0 mutation test units
[INFO] …
Run Code Online (Sandbox Code Playgroud) 根据Pitest的文档,似乎这应该很简单,但它给我带来了一些麻烦.我应该能够拥有
java -cp <your classpath> \
org.pitest.mutationtest.commandline.MutationCoverageReport \
--reportDir c:\\mutationReports \
--targetClasses example.foo.* \
--sourceDirs c:\\myProject\\src \
--targetTests example.foo*
Run Code Online (Sandbox Code Playgroud)
但我不知道我的项目应该是什么,例如"<your classpath>".
我的项目的文件结构如下所示:
最后,我想把它放在一个.bat文件中,然后在TeamCity上为我的CI运行它
任何帮助,将不胜感激!
我必须从 PIT 的执行中排除我的集成测试。excludedTestClasses
从版本 1.3.0 开始有一个选项。我试图通过 PIT 的 Maven 插件的以下配置来传递这些测试。
<plugin>
<groupId>org.pitest</groupId>
<artifactId>pitest-maven</artifactId>
<version>1.3.1</version>
<configuration>
<verbose>true</verbose>
<mutationThreshold>80</mutationThreshold>
<targetClasses>
<param>de.comp.proj.*</param>
</targetClasses>
<excludedTestClasses>
<param>**/*IT.java</param>
</excludedTestClasses>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
然而,PIT 仍在执行所有带有后缀的测试IT
。我看了一下来源,但在晚上迷路了;-)
那么,我怎样才能跳过我的集成测试呢?
我有一个带有 JUnit 5 测试的小型 Java 11 示例,结果是:
改变条件边界 ? 幸存下来
主要类:
public final class CheckerUtils
{
private CheckerUtils()
{
super();
}
public static int checkPort(final int port)
{
if (port < 0)
{
throw new IndexOutOfBoundsException("Port number out of range!");
}
return port;
}
}
Run Code Online (Sandbox Code Playgroud)
测试类:
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import org.junit.jupiter.api.Test;
import de.powerstat.security.CheckerUtils;
public final class CheckerUtilsTests
{
@Test
public void checkPortOk()
{
final int port = 1023;
final int resultPort = CheckerUtils.checkPort(port);
assertEquals(port, resultPort, "Port not …
Run Code Online (Sandbox Code Playgroud) 我想整合一些突变测试,以确保我的junit测试的质量.我希望将结果放在我项目的声纳仪表板中.
该声纳pitest插件似乎做我想做的,但也有一些问题与Maven 3,它仍然是正在开发中.
有没有人试过这个插件?还有其他选择吗?
我应该如何摆脱这个警告并为pitest添加超时常量?
我的命令是:
mvn jacoco:report org.pitest:pitest-maven:mutationCoverage sonar:sonar -Dpitest.timeoutConst=8000
Run Code Online (Sandbox Code Playgroud)
但它会引发:警告:由于TIMED_OUT,Slave异常退出
我试图排除PIT变异I/O方法,如"关闭"和"刷新".这是我的Maven配置:
<plugin>
<groupId>org.pitest</groupId>
<artifactId>pitest-maven</artifactId>
<version>1.1.3</version>
<configuration>
<targetClasses>
<param>my.package.*.*</param>
</targetClasses>
<targetTests>
<param>my.package.*.*</param>
</targetTests>
<excludedClasses>
<param>my.generated.*</param>
<param>**.*IT</param>
</excludedClasses>
<excludedMethods>
<param>close</param>
<param>flush</param>
</excludedMethods>
<reportSets>
<reportSet>
<reports>
<report>report</report>
</reports>
</reportSet>
</reportSets>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
excludedClasses似乎正在工作,但不是excludedMethods.即PIT结果仍然表示删除"关闭"和"刷新"调用对测试结果没有影响.
问题:我错过了什么?
pitest ×10
java ×6
maven ×3
maven-3 ×3
unit-testing ×2
command-line ×1
java-11 ×1
junit5 ×1
maven-plugin ×1
mutation ×1
sonarqube ×1
spring ×1
spring-boot ×1
teamcity ×1