【问题标题】:gwt-maven-plugin run tests on wrong addressgwt-maven-plugin 在错误的地址上运行测试
【发布时间】:2015-10-23 13:22:51
【问题描述】:

当 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:run 它从 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 上开始测试呢?

【问题讨论】:

    标签: maven gwt gwt-maven-plugin


    【解决方案1】:

    测试使用InetAddress.getLocalHost().getHostAddress(),因此除了更改InetAddress.getLocalHost() 的JVM 行为外,没有其他方法可以更改它。
    JUnitShell 的行为是允许 remote testing 无需重新配置(与需要 -bindAddress 的 DevMode 相反)。

    一种解决方案是创建一个自定义“运行样式”,继承com.google.gwt.junit.RunStyleHtmlUnit 并覆盖getLocalHostName() 以返回127.0.0.1,并通过&lt;mode&gt;name.of.your.CustomRunStyleHtmlUnit&lt;/mode&gt; 使用它。

    【讨论】:

      猜你喜欢
      • 2017-11-26
      • 2012-02-11
      • 1970-01-01
      • 1970-01-01
      • 2018-12-27
      • 1970-01-01
      • 2012-02-04
      • 2019-05-08
      • 1970-01-01
      相关资源
      最近更新 更多