2016-12-06 154 views
0

我想設置PIT爲番石榴(http://pitest.org/)做突變檢測測試,但我在嘗試運行時遇到以下錯誤。這是我的錯誤:設置PITest爲番石榴

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 tests pass but PIT says the suite isn't green,我想「你的代碼庫中是否包含可變靜態?(例如在單例中)」是問題所在,但我不知道如何解決它。在測試套件具有一些隱藏順序依賴的情況下,如何使它可以運行PIT?或者測試套件是否與PIT不兼容?

回答

0

問題很可能是PIT正在運行GWT測試用例 - 這些不是正常意義上的單元測試,因爲代碼不在JVM中運行,而是轉換爲Java腳本並運行在瀏覽器。

PIT僅適用於與運行測試的代碼在相同的JVM中運行的代碼。

如果排除番石榴gwt測試案例PIT會更快樂。