标签: pitest

JUnit测试通过,但PIT称该套件不是绿色的

在尝试运行PIT突变测试时,我收到以下错误:

mutationCoverage failed:计算线覆盖时,所有测试都没有通过而没有突变.变异测试需要绿色套件.

当我进行正常的测试构建时,测试运行得很好但是在运行突变测试阶段时,他们认为会失败,但没有提供有关原因的详细信息.我已经解决了PIT测试常见问题解答中列出的原因,但我仍然不知道可能出现的问题.

我试过了:

  • 将-Dthreads = 1选项添加到任何多线程问题的规则中
  • 找不到任何系统属性唯一的失败的几个测试
  • 正常运行时不会忽略测试

我还应该尝试一些其他的事情吗?或者其他方法来调试可能发生的事情?

java unit-testing mutation-testing pitest

22
推荐指数
1
解决办法
6440
查看次数

当应该使用具有自动注入字段的方法时,突变不会被杀死

我有以下内容:

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)

java spring mutation-testing pitest spring-boot

13
推荐指数
1
解决办法
1245
查看次数

我的 PITEST 无法运行。覆盖生成minion异常退出。我需要帮助来正确配置我的 pom.xml

运行时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)

java mutation-testing maven-3 pitest junit-jupiter

13
推荐指数
2
解决办法
1万
查看次数

PTTest失败并且不会产生突变覆盖

我想生成突变测试覆盖率.我在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)

mutation pitest

8
推荐指数
1
解决办法
6009
查看次数

从命令行运行Pitest

根据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运行它

任何帮助,将不胜感激!

java teamcity command-line mutation-testing pitest

7
推荐指数
1
解决办法
1105
查看次数

从 PIT 执行中排除测试

我必须从 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。我看了一下来源,但在晚上迷路了;-)

那么,我怎样才能跳过我的集成测试呢?

java unit-testing mutation-testing maven pitest

7
推荐指数
3
解决办法
6792
查看次数

PiTest“改变条件边界突变幸存”无缘无故?

我有一个带有 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)

pitest junit5 java-11

7
推荐指数
1
解决办法
4568
查看次数

Sonar Pitest插件

我想整合一些突变测试,以确保我的junit测试的质量.我希望将结果放在我项目的声纳仪表板中.

声纳pitest插件似乎做我想做的,但也有一些问题与Maven 3,它仍然是正在开发中.

有没有人试过这个插件?还有其他选择吗?

mutation-testing maven-3 pitest sonarqube

6
推荐指数
1
解决办法
1976
查看次数

Pitest警告:由于TIMED_OUT,从站异常退出

我应该如何摆脱这个警告并为pitest添加超时常量?

我的命令是:

mvn jacoco:report org.pitest:pitest-maven:mutationCoverage sonar:sonar -Dpitest.timeoutConst=8000
Run Code Online (Sandbox Code Playgroud)

但它会引发:警告:由于TIMED_OUT,Slave异常退出

java maven-plugin maven-3 maven pitest

6
推荐指数
1
解决办法
3589
查看次数

pitest excludedMethods maven

我试图排除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结果仍然表示删除"关闭"和"刷新"调用对测试结果没有影响.

问题:我错过了什么?

mutation-testing maven pitest

6
推荐指数
1
解决办法
1777
查看次数