2013-04-15 104 views
0

我有一個與春天的Maven項目。我們也有很多JUnit測試課程。我們正在使用Eclipse。時不時地 - 實際上 - 實際上 - 日食顯示一些(不是全部)測試類爲紅色...聲稱它不能找到導入。看看Eclipse錯誤日誌,我可以看到很多這些錯誤消息(但對於不同的測試類ofc)。Eclipse無法找到一些JUnit文件

發生了什麼事?我的同事在同一個項目中工作並沒有得到這個錯誤。我們正在使用Eclipse Juno SR2。

org.eclipse.core.runtime.CoreException: File not found: C:\xxx\target\test-classes\com\yyy\vet\zzz\service\TradeWashTest.class. 
    at org.eclipse.core.internal.filesystem.Policy.error(Policy.java:55) 
    at org.eclipse.core.internal.filesystem.local.LocalFile.openInputStream(LocalFile.java:377) 
    at org.eclipse.core.internal.localstore.FileSystemResourceManager.read(FileSystemResourceManager.java:797) 
    at org.eclipse.core.internal.resources.File.getContents(File.java:289) 
    at org.eclipse.jdt.internal.core.util.Util.getResourceContentsAsByteArray(Util.java:1132) 
    at org.eclipse.jdt.internal.core.builder.IncrementalImageBuilder.writeClassFileCheck(IncrementalImageBuilder.java:888) 
    at org.eclipse.jdt.internal.core.builder.IncrementalImageBuilder.writeClassFileContents(IncrementalImageBuilder.java:830) 
    at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.writeClassFile(AbstractImageBuilder.java:857) 
    at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.acceptResult(AbstractImageBuilder.java:188) 
    at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:510) 
    at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:365) 
    at org.eclipse.jdt.internal.core.builder.IncrementalImageBuilder.compile(IncrementalImageBuilder.java:329) 
    at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile(AbstractImageBuilder.java:302) 
    at org.eclipse.jdt.internal.core.builder.IncrementalImageBuilder.build(IncrementalImageBuilder.java:134) 
    at org.eclipse.jdt.internal.core.builder.JavaBuilder.buildDeltas(JavaBuilder.java:265) 
    at org.eclipse.jdt.internal.core.builder.JavaBuilder.build(JavaBuilder.java:193) 
    at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:726) 
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) 
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:199) 
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:239) 
    at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:292) 
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) 
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:295) 
    at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:351) 
    at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:374) 
    at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:143) 
    at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:241) 
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53) 
Caused by: java.io.FileNotFoundException: C:\dev\xxx\target\test-classes\com\yyy\vet\zzz\service\TradeWashTest.class (The system cannot find the path specified) 
    at java.io.FileInputStream.open(Native Method) 
    at java.io.FileInputStream.<init>(Unknown Source) 
    at org.eclipse.core.internal.filesystem.local.LocalFile.openInputStream(LocalFile.java:368) 
    ... 26 more 

回答

2

問題可能出現在jar依賴項(尤其是如果你使用的是mocks)。你需要執行兩個步驟來找出問題所在:

1.使用maven運行單元測試(如果它工作,可以轉到步驟2); 2.在Eclipse中查看jar順序(項目設置 - > java構建路徑 - >順序和設置)。

如果你說,它爲你的同事,你需要與你的同事罐子的順序來比較你的罐子爲了