无法调试 gwt 2.8 和 java 1.8 版本的 gwt 测试

Unable to debug gwt test for gwt 2.8 and java 1.8 version

我已经将 gwt 版本升级到 2.8 和 java 1.8。使用 gwt 2.7 和 java 1.7 测试 运行 没问题。我是否需要在 gwt.xml 中添加额外配置或在 pom

中添加任何依赖项

pom :

        <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-servlet</artifactId>
            <scope>2.8</scope>
        </dependency>
        <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-user</artifactId>
            <scope>2.8</scope>
        </dependency>
        <dependency>
            <groupId>com.google.gwt</groupId>
            <artifactId>gwt-dev</artifactId>
            <scope>2.8</scope>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava-gwt</artifactId>
            <version>20.0</version>
        </dependency>

测试代码:

public class Test extends GWTTestCase {

    Logger logger = Logger.getLogger(this.getClass().getCanonicalName());

    /* (non-Javadoc)
     * @see com.google.gwt.junit.client.GWTTestCase#getModuleName()
     */
    @Override
    public String getModuleName() {
        return "org.field.TestJUnit";
    }

    public void testRenderAndBindTopScene() {
        GWT.log("hi");
        PageEx pageEx = GWT.create(PageEx.class);
    }
}

TestJUnit.gwt.xml :

<?xml version="1.0" encoding="UTF-8"?>
<module rename-to="Field">
    <!-- Inherit our applications main module. -->
    <inherits name='org.field.Field' />


    <source path="client" />
    <source path="shared" />

</module>

从 GWT 2.8 开始,经典开发模式现已(正式)弃用,并默认在生产模式下测试 运行(即编译为 Java脚本)。

这意味着您不能在 Java 代码中设置断点并期望在 Java 调试器中到达(因为它们是常规的 JUnit 3 测试,由标准 JUnit 运行ner,实际上会调用一些方法,但不会调用测试方法本身)。
您可以(暂时)通过在 -Dgwt.args= 系统 属性、as hinted in the release notes.

中传递 -devMode 来为测试重新启用开发模式

或者,您可以 运行 在 "manual" 模式下进行测试(您将获得一个 URL 在浏览器中打开,您可以在其中调试 JavaScript),或者当 运行ning 使用 HtmlUnit 运行 样式(默认)进行测试时,您可以传递 -Dgwt.htmlunit.debug 系统 属性 以显示调试器 window (注意:我不知道怎么用)

…或"debug" "good old way" 通过记录事物; and/or 制作一个小的复用案例作为 GWT 应用程序,您可以在浏览器中 运行。

这是对 Thomas Broyer 回答的评论。

要在 "manual" 模式下进行 运行 测试,您必须指定 运行Sytle,最好将样式更改为 PRETTY。

-Dgwt.args="-runStyle Manual:1 -style PRETTY"

Eclipse JUnit VM settings example

要在 GWT 2.8 for eclipse IDE 中启用开发模式以调试测试用例 IDE 请按照以下步骤进行操作,这肯定会对您有所帮助:

  1. 右键单击编写测试用例的项目。
  2. select 作为配置进行调试。
  3. 导航左侧 select 您要调试的测试用例。
  4. 然后 select 参数选项卡并添加 -Dgwt.args="-devMode" 参数 在为 VM 参数指定的框中。
  5. here is the screen-shot