首页 > 解决方案 > PITest 在测试运行开始时挂起

问题描述

我正在尝试在 light4j ( https://github.com/networknt/light-4j ) 的主版本上运行 PITest,这是我或多或少随机选择的一个项目,用于在真实世界代码上试用 PITest。

除了 light4j 的“cient”模块外,大多数模块的测试都完成了。跑步时

mvn -X test org.pitest:pitest-maven:mutationCoverage

在 light-4j/client 文件夹中,正常的单元测试运行完成(所有测试都正常,跳过了 3 个),但 PITest 似乎没有生成和执行突变。最后的消息是

[INFO] Adding org.pitest:pitest to SUT classpath
[INFO] Mutating from /Users/jan/dev/inno/light-4j/client/target/classes
[INFO] Defaulting target classes to match packages in build directory
/-\|/-\|/-\|/-\|/-stderr  : WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.xnio.nio.NioXnio$2 (file:/Users/jan/.m2/repository/org/jboss/xnio/xnio-nio/3.3.8.Final/xnio-nio-3.3.8.Final.jar) to constructor sun.nio.ch.KQueueSelectorstderr  : Provider()
WARNING: Please consider reporting this to the maintainers of org.xnio.nio.NioXnio$2
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in astderr  :  future release

之后什么也没有发生。

light4j 的正常构建成功完成。

可能是什么问题呢?

[2020 年 2 月 5 日编辑:我已经分叉了 light4j 存储库:https ://github.com/jvermeir/light-4j 然后我执行了正常构建mvn clean install,因此所有工件都在我的本地 maven 存储库中。接下来我在 light4j 项目的根级别更改了 pom.xml,添加

<plugin>
    <groupId>org.pitest</groupId>
    <artifactId>pitest-maven</artifactId>
    <version>1.4.10</version>
    <dependencies>
<!--                    <dependency>-->
<!--                        <groupId>org.pitest</groupId>-->
<!--                        <artifactId>pitest-junit5-plugin</artifactId>-->
<!--                        <version>0.10</version>-->
<!--                    </dependency>-->
    </dependencies>
</plugin>

在构建部分最后我在客户端文件夹中启用了 PiTest 执行了测试:mvn -X test org.pitest:pitest-maven:mutationCoverage > ../buildlog.txt 这会生成一个 build.txt 文件,但也会在终端中显示几行:

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

17:10:32 PIT >> INFO : MINION : 17:10:32 PIT >> INFO : Found  18 tests

17:10:32 PIT >> INFO : MINION : 17:10:32 PIT >> INFO : Dependency analysis reduced number of potential tests by 0

17:10:32 PIT >> INFO : MINION : 17:10:32 PIT >> INFO : 18 tests received

17:10:33 PIT >> INFO : MINION : WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.powermock.reflect.internal.WhiteboxImpl (file:/Users/jan/.m2/repository/org/powermock/powermock-reflect/2.0.2/powermock-reflect-2.0.2.jar) to method java
17:10:33 PIT >> INFO : MINION : .lang.Object.clone()
WARNING: Please consider reporting this to the maintainers of org.powermock.reflect.internal.WhiteboxImpl
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access
17:10:33 PIT >> INFO : MINION :  operations will be denied in a future release

17:11:24 PIT >> INFO : MINION : 17:11:24 PIT >> WARNING : More threads at end of test (46) com.networknt.client.Http2ClientTest than start. (5)

17:11:24 PIT >> INFO : Calculated coverage in 54 seconds.
17:11:25 PIT >> INFO : Created  92 mutation test units

build.txt 的结尾如下所示:

[INFO] Adding org.pitest:pitest to SUT classpath
[INFO] Mutating from /Users/jan/dev/inno/light4jfork/light-4j/client/target/classes
[INFO] Defaulting target classes to match packages in build directory
-stderr  : WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.xnio.nio.NioXnio$2 (file:/Users/jan/.m2/repository/org/jboss/xnio/xnio-nio/3.3.8.Final/xnio-nio-3.3.8.Final.jar) to constructor sun.nio.ch.KQueueSelectorstderr  : Provider()
WARNING: Please consider reporting this to the maintainers of org.xnio.nio.NioXnio$2
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in astderr  :  future release

标签: javamavenpitest

解决方案


我也试过了,它停在客户端模块。我只是想知道我们是否应该将 Pitest-maven 插件添加到 pom.xml

[INFO] Mutating from /home/steve/networknt/light-4j/client/target/classes
[INFO] Defaulting target classes to match packages in build directory
7:35:54 p.m. PIT >> INFO : Verbose logging is disabled. If you encounter a problem, please enable it before reporting an issue.
7:35:54 p.m. PIT >> INFO : Sending 147 test classes to minion
7:35:54 p.m. PIT >> INFO : Sent tests to minion
7:35:54 p.m. PIT >> INFO : MINION : 7:35:54 p.m. PIT >> INFO : Checking environment

7:35:55 p.m. PIT >> INFO : MINION : 7:35:55 p.m. PIT >> INFO : Found  18 tests

7:35:55 p.m. PIT >> INFO : MINION : 7:35:55 p.m. PIT >> INFO : Dependency analysis reduced number of potential tests by 0

7:35:55 p.m. PIT >> INFO : MINION : 7:35:55 p.m. PIT >> INFO : 18 tests received

7:35:56 p.m. PIT >> INFO : MINION : WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.powermock.reflect.internal.WhiteboxImpl (file:/home/steve/.m2/repository/org/powermock/powermock-reflect/2.0.2/powermock-reflect-2.0.2.jar) to method jav
7:35:56 p.m. PIT >> INFO : MINION : a.lang.Object.clone()
WARNING: Please consider reporting this to the maintainers of org.powermock.reflect.internal.WhiteboxImpl
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal acces
7:35:56 p.m. PIT >> INFO : MINION : s operations will be denied in a future release


推荐阅读