我知道以前曾以各种形式提出过这个问题,但我已经检查了所有答案,并且认为我们已经将所有答案都排除在外了。
错误:
java.lang.NoClassDefFoundError: com/lgc/infra/geometry/Coord1Val
at com.lgc.infra.geometry.Coords.coord(Coords.java:89)
at com.lgc.infra.geometry.Coords.<clinit>(Coords.java:24)
at com.geoteric.lfd.eos.ReallyBasicTest.make_a_simple_coord(ReallyBasicTest.java:17)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:24)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:78)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:212)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:68)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)
Caused by: java.lang.ClassNotFoundException: com.lgc.infra.geometry.Coord1Val
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 37 more
代码:
package com.geoteric.lfd.eos;
import com.lgc.infra.geometry.Coord3;
import com.lgc.infra.geometry.Coords;
import org.junit.Test;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertThat;
/**
* Created by TClarke on 27/03/2015.
*/
public class ReallyBasicTest {
@Test
public void make_a_simple_coord()
{
Coord3 c3 = Coords.coord(1.0f, 2.0f, 3.0f);
assertThat(c3.getX(), equalTo(1.0));
}
}
ClassFile的路径:
D:\ffa_dev\link-for-decisionspace\ext\dssdk\com_lgc_dsp-core_sdk.jar!\com\lgc\infra\geometry\Coords.class
模块结构的屏幕截图:
Test Runner Config的屏幕截图:
内置到实际项目中时,相关代码功能很好。那么,关于我可能错过的任何建议吗?
最佳答案
我认为您的.iml没有更新。您是否尝试过重新创建项目/模块.iml文件。如果它是Maven项目,则可以通过命令重新创建它
mvn idea:idea
.iml更新后,刷新项目并重新运行测试
关于intellij-idea - 运行IntelliJ测试时出现IntelliJ NoClassDefFoundError,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/29305557/