1

我正在尝试为 Guava ( http://pitest.org/ )设置 PIT以进行突变充分性测试,但在尝试运行它时出现以下错误。这是我得到的错误:

12:19:47 PM PIT >> INFO : Sending 32 test classes to minion
12:19:47 PM PIT >> INFO : Sent tests to minion
12:19:48 PM PIT >> INFO : MINION : 12:19:48 PM PIT >> INFO : Checking environment

12:19:48 PM PIT >> INFO : MINION : 12:19:48 PM PIT >> INFO : Found  40 tests

12:19:48 PM PIT >> INFO : MINION : 12:19:48 PM PIT >> INFO : Dependency analysis reduced number of potential tests by 0

12:19:48 PM PIT >> INFO : MINION : 12:19:48 PM PIT >> INFO : 40 tests received

12:19:53 PM PIT >> INFO : MINION : Dec 06, 2016 12:19:53 PM java.util.prefs.WindowsPreferences <init>
WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5.

12:19:54 PM PIT >> INFO : MINION : 12:19:54 PM PIT >> WARNING : More threads at end of test (7) testCantRemove(com.google.common.collect.AbstractIteratorTest_gwt) than start. (5)


/
-
|
/
\
-12:19:54 PM PIT >> WARNING : Description [testClass=com.google.common.collect.AbstractIteratorTest_gwt, name=testCantRemove(com.google.common.collect.AbstractIteratorTest_gwt)] did not pass without mutation.
12:19:54 PM PIT >> WARNING : Description [testClass=com.google.common.collect.AbstractIteratorTest_gwt, name=testDefaultBehaviorOfNextAndHasNext(com.google.common.collect.AbstractIteratorTest_gwt)] did not pass without mutation.
12:19:54 PM PIT >> WARNING : Description [testClass=com.google.common.collect.AbstractIteratorTest_gwt, name=testDefaultBehaviorOfPeek(com.google.common.collect.AbstractIteratorTest_gwt)] did not pass without mutation.

/12:19:54 PM PIT >> WARNING : Description [testClass=com.google.common.collect.AbstractIteratorTest_gwt, name=testDefaultBehaviorOfPeekForEmptyIteration(com.google.common.collect.AbstractIteratorTest_gwt)] did not pass without mutation.
12:19:54 PM PIT >> WARNING : Description [testClass=com.google.common.collect.AbstractIteratorTest_gwt, name=testException(com.google.common.collect.AbstractIteratorTest_gwt)] did not pass without mutation.
12:19:54 PM PIT >> WARNING : Description [testClass=com.google.common.collect.AbstractIteratorTest_gwt, name=testExceptionAfterEndOfData(com.google.common.collect.AbstractIteratorTest_gwt)] did not pass without mutation.

\12:19:54 PM PIT >> WARNING : Description [testClass=com.google.common.collect.AbstractIteratorTest_gwt, name=testReentrantHasNext(com.google.common.collect.AbstractIteratorTest_gwt)] did not pass without mutation.
12:19:54 PM PIT >> WARNING : Description [testClass=com.google.common.collect.AbstractIteratorTest_gwt, name=testSneakyThrow(com.google.common.collect.AbstractIteratorTest_gwt)] did not pass without mutation.

/
|
/
|
/12:19:54 PM PIT >> WARNING : Description [testClass=com.google.common.collect.AbstractMapEntryTest_gwt, name=testEquals(com.google.common.collect.AbstractMapEntryTest_gwt)] did not pass without mutation.
12:19:54 PM PIT >> WARNING : Description [testClass=com.google.common.collect.AbstractMapEntryTest_gwt, name=testEqualsNull(com.google.common.collect.AbstractMapEntryTest_gwt)] did not pass without mutation.
12:19:54 PM PIT >> WARNING : Description [testClass=com.google.common.collect.AbstractMapEntryTest_gwt, name=testHashCode(com.google.common.collect.AbstractMapEntryTest_gwt)] did not pass without mutation.
12:19:54 PM PIT >> WARNING : Description [testClass=com.google.common.collect.AbstractMapEntryTest_gwt, name=testHashCodeNull(com.google.common.collect.AbstractMapEntryTest_gwt)] did not pass without mutation.
12:19:54 PM PIT >> WARNING : Description [testClass=com.google.common.collect.AbstractMapEntryTest_gwt, name=testToString(com.google.common.collect.AbstractMapEntryTest_gwt)] did not pass without mutation.
12:19:54 PM PIT >> WARNING : Description [testClass=com.google.common.collect.AbstractMapEntryTest_gwt, name=testToStringNull(com.google.common.collect.AbstractMapEntryTest_gwt)] did not pass without mutation.

|12:19:54 PM PIT >> WARNING : Description [testClass=com.google.common.collect.AbstractSequentialIteratorTest_gwt, name=testBroken(com.google.common.collect.AbstractSequentialIteratorTest_gwt)] did not pass without mutation.
12:19:54 PM PIT >> WARNING : Description [testClass=com.google.common.collect.AbstractSequentialIteratorTest_gwt, name=testDoubler(com.google.common.collect.AbstractSequentialIteratorTest_gwt)] did not pass without mutation.
12:19:54 PM PIT >> WARNING : Description [testClass=com.google.common.collect.AbstractSequentialIteratorTest_gwt, name=testEmpty(com.google.common.collect.AbstractSequentialIteratorTest_gwt)] did not pass without mutation.
12:19:54 PM PIT >> WARNING : Description [testClass=com.google.common.collect.AbstractSequentialIteratorTest_gwt, name=testSampleCode(com.google.common.collect.AbstractSequentialIteratorTest_gwt)] did not pass without mutation.
12:19:54 PM PIT >> INFO : Calculated coverage in 9 seconds.
Exception in thread "main" org.pitest.help.PitHelpError: All tests did not pass without mutation when calculating line coverage. Mutation testing requires a green suite.
See http://pitest.org for more details.
    at org.pitest.coverage.execute.DefaultCoverageGenerator.verifyBuildSuitableForMutationTesting(DefaultCoverageGenerator.java:109)
    at org.pitest.coverage.execute.DefaultCoverageGenerator.calculateCoverage(DefaultCoverageGenerator.java:94)
    at org.pitest.coverage.execute.DefaultCoverageGenerator.calculateCoverage(DefaultCoverageGenerator.java:49)
    at org.pitest.mutationtest.tooling.MutationCoverage.runReport(MutationCoverage.java:110)
    at org.pitest.mutationtest.tooling.EntryPoint.execute(EntryPoint.java:103)
    at org.pitest.mutationtest.tooling.EntryPoint.execute(EntryPoint.java:45)
    at org.pitest.mutationtest.commandline.MutationCoverageReport.runReport(MutationCoverageReport.java:76)
    at org.pitest.mutationtest.commandline.MutationCoverageReport.main(MutationCoverageReport.java:45)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)

基本上,要么 PIT 没有检测到测试,要么测试没有在 PIT 中正常运行并且所有测试都失败了。我读了这篇文章:JUnit 测试通过但 PIT 说套件不是绿色的,我认为“你的代码库是否包含可变静态状态?(例如在单例中)”是问题,但我不知道如何解决它。如果测试套件具有一些隐藏的顺序依赖关系,如何制作它以便我可以在其上运行 PIT?还是测试套件与 PIT 根本不兼容?

4

1 回答 1

1

问题很可能是 PIT 正在运行 GWT 测试用例——这些不是正常意义上的单元测试,因为代码不是在 JVM 中运行,而是被翻译成 Java 脚本并在浏览器中运行。

PIT 仅适用于与运行它的测试在同一 JVM 中运行的代码。

如果排除 guava gwt 测试用例 PIT 会更快乐。

于 2017-01-05T11:02:05.260 回答