当maven使用gwt-maven-plugin启动测试时,它会启动服务器,并在我的示例中使用错误的ip。
Starting http://10.0.14.67:60281/com.something.GwtTest.JUnit/junit-standards.html?gwt.codesvr=10.0.14.67:60278 on browser FF17访问被拒绝的错误。我想让它在127.0.0.1上开始测试,但不知道怎么做。但是如果我运行gwt插件,不是gwt:test,而是gwt:运行它从127.0.0.1开始,一切都很好!我在maven插件中有这样的配置
<failOnError>true</failOnError>
<runTarget>http://127.0.0.1:8080/</runTarget>
<hostedWebapp>${project.build.directory}/${project.build.finalName}-gwt</hostedWebapp>
<noServer>true</noServer>
<includes>**/*TestSuiteGWT.java</includes>
<mode>htmlunit</mode>那么,我如何使它在相同的127.0.0.1上开始测试呢?
发布于 2015-10-23 14:02:46
测试使用InetAddress.getLocalHost().getHostAddress(),因此除了更改InetAddress.getLocalHost()的行为之外,没有其他方法可以更改它。
JUnitShell的这种行为是允许不需要重新配置的远程测试 (与需要-bindAddress的DevMode相反)。
一个解决方案是创建一个自定义的“运行样式”,继承com.google.gwt.junit.RunStyleHtmlUnit并重写getLocalHostName()以返回127.0.0.1,并通过<mode>name.of.your.CustomRunStyleHtmlUnit</mode>使用它。
https://stackoverflow.com/questions/33303416
复制相似问题