首页 > 解决方案 > 使用 GWT `tbroyer` maven 插件时运行 GWT JUnit 测试的正确方法是什么?

问题描述

为使用tbroyer maven 插件的 GWT 项目运行 JUnit 测试的正确方法是什么

我创建了一个示例应用程序来展示抛出的失败测试

Loading inherited module 'com.todogwt.App'
   [ERROR] Unable to find 'com/todogwt/App.gwt.xml' on your classpath; could be a typo, or maybe you forgot to include a classpath entry for source?

这是代码:https ://github.com/incube8r/todogwt

测试同样非常简单

public class TestHelloWorld extends GWTTestCase {

    @Override
    public String getModuleName() {
        return "com.todogwt.App";
    }

    public void test() {
        Window.alert("Hello world!");
        Console.log("Hello world!");
        delayTestFinish(1000);
        finishTest();
    }

}

测试module.gwt.xml位于

src/test/module.gwt.xml

tbroyer使用 GWT maven 插件时运行 JUnit 测试的正确方法是什么?

标签: javagwt

解决方案


gwt:test默认情况下希望您使用测试套件:https ://tbroyer.github.io/gwt-maven-plugin/test-mojo.html#includes ;您可以运行,-Dtest=TestHelloWorld但您必须更新到最新版本的 gwt-maven-plugin(目前为 1.0-rc-10);或者您可以重新定义<includes>以匹配您的测试。

最后但并非最不重要的src/test/module.gwt.xml是,不被任何东西使用;只有src/main/module.gwt.xml是。但是,这些文件之间没有任何区别,而您的问题实际上是您的测试类不在模块的源路径中:将其移动到client子包以使其运行(并通过)。


推荐阅读