java.lang.NoSuchFieldError:运行JUnit测试时的EDGE

时间:2017-11-20 14:00:25

标签: java intellij-idea gwt junit

在IntelliJ

上运行JUnit测试时出错
java.lang.NoSuchFieldError: EDGE

    at com.google.gwt.junit.RunStyleHtmlUnit.<clinit>(RunStyleHtmlUnit.java:288)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:264)
    at com.google.gwt.junit.JUnitShell.createRunStyle(JUnitShell.java:1190)
    at com.google.gwt.junit.JUnitShell.doStartup(JUnitShell.java:917)
    at com.google.gwt.dev.DevModeBase.startUp(DevModeBase.java:982)
    at com.google.gwt.junit.JUnitShell.getUnitTestShell(JUnitShell.java:673)
    at com.google.gwt.junit.JUnitShell.runTest(JUnitShell.java:647)
    at com.google.gwt.junit.client.GWTTestCase.runTest(GWTTestCase.java:421)
    at junit.framework.TestCase.runBare(TestCase.java:130)
    at junit.framework.TestResult$1.protect(TestResult.java:106)
    at junit.framework.TestResult.runProtected(TestResult.java:124)
    at junit.framework.TestResult.run(TestResult.java:109)
    at junit.framework.TestCase.run(TestCase.java:120)
    at com.google.gwt.junit.client.GWTTestCase.run(GWTTestCase.java:247)
    at junit.framework.TestSuite.runTest(TestSuite.java:230)
    at junit.framework.TestSuite.run(TestSuite.java:225)
    at junit.textui.TestRunner.doRun(TestRunner.java:121)
    at com.intellij.junit3.JUnit3IdeaTestRunner.doRun(JUnit3IdeaTestRunner.java:113)
    at junit.textui.TestRunner.doRun(TestRunner.java:114)
    at com.intellij.junit3.JUnit3IdeaTestRunner.startRunnerWithArgs(JUnit3IdeaTestRunner.java:45)
    at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

有什么可以解决这个问题?

1 个答案:

答案 0 :(得分:1)

正如其他渠道所提到的,这可能是由于您使用了非标准gwt fork而不再隐含捆绑htmlunit。

只需添加:

        <dependency>
            <groupId>net.sourceforge.htmlunit</groupId>
            <artifactId>htmlunit</artifactId>
            <version>2.19</version>
        </dependency>