似乎这是一个很常见的问题,我个人至少偶然发现了几次。
一些主要原因是:
targetTests:pitest 找不到测试assert关键字使用不当:pitest无法定位junit测试然而,今天我偶然发现了一个新的 0 测试案例,我很难解决。让我们考虑这个项目:https : //github.com/bonnyfone/vectalign。
这是一个小项目,只包含一个测试类:
src
|
+- main
| |
| ...
|
+- test
|
+- java
|
+- VectAlignTest.java
Run Code Online (Sandbox Code Playgroud)
我添加了 pitest 到pom.xml:
<plugin>
<groupId>org.pitest</groupId>
<artifactId>pitest-maven</artifactId>
<version>1.3.2</version>
</plugin>
Run Code Online (Sandbox Code Playgroud)
我运行命令mvn clean test org.pitest:pitest-maven:mutationCoverage。虽然测试运行得很好,但由于某种原因,pitest 无法找到它们:
12:23:16 PM PIT >> INFO : MINION : 12:23:16 PM PIT >> INFO : Found 0 tests …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 JaCoCo 在这个项目中测量覆盖率:https : //github.com/square/retrofit
一切似乎都运行良好,但由于某种原因,一些曾经可以工作的测试在使用 JaCoCo 运行时代理时失败了。
这是我的(有趣的部分)pom.xml:
...
<plugins>
...
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.17</version>
<executions>
<execution>
<id>default-test</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
<configuration>
<!-- Sets the VM argument line used when unit tests are run. -->
<argLine>${surefireArgLine}</argLine>
</configuration>
</plugin>
...
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.0</version>
<executions>
<!--
Prepares the property pointing to the JaCoCo runtime agent which
is passed as VM argument when Maven the Surefire plugin is executed.
-->
<execution>
<id>pre-unit-test</id>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration> …Run Code Online (Sandbox Code Playgroud) 我有一个使用工具链编译的非常简单的arm可执行文件arm-linux-gnueabi。qemu-arm我可以毫无问题地执行它:
$ qemu-arm -L /usr/arm-linux-gnueabi/ ./a.out
Hello world !
Run Code Online (Sandbox Code Playgroud)
不带任何参数运行链接器似乎也有效:
qemu-arm /usr/arm-linux-gnueabi/lib/ld-linux.so.3
Usage: ld.so [OPTION]... EXECUTABLE-FILE [ARGS-FOR-PROGRAM...]
You have invoked `ld.so', the helper program for shared library executables.
...
Run Code Online (Sandbox Code Playgroud)
但是,如果我希望链接器运行我的可执行文件,则会发生以下情况:
$ qemu-arm -L /usr/arm-linux-gnueabi/ /usr/arm-linux-gnueabi/lib/ld-linux.so.3 a.out
a.out: error while loading shared libraries: a.out: cannot open shared object file
Run Code Online (Sandbox Code Playgroud)
这是 strace 的输出:https://pastebin.com/uJ7AhBdh
知道为什么会发生这种情况吗?