案子
我正在尝试GWTTestCase
为某个类编写一个,用作我正在构建的历史浏览工具栏组件的演示者。
问题
一个(或多个)脚本显然没有为 jUnit 测试环境加载。运行应用程序(开发模式)时一切正常,但是当我尝试运行测试用例时,应用程序(Web 服务器和用户代理)无法加载,并引发以下异常(为简单起见缩短了堆栈跟踪) :
com.gargoylesoftware.htmlunit.ScriptException: Wrapped com.gargoylesoftware.htmlunit.ScriptException: Exception invoking jsxFunction_write at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:601) at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:537) at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:538) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScriptEngine.java:499) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:595) ... 41 more
...
Caused by: com.gargoylesoftware.htmlunit.ScriptException: Wrapped com.gargoylesoftware.htmlunit.ScriptException: ReferenceError: "Raphael" is not defined. (http://192.168.10.32:3692/com.gigaspaces.admin.webui.Gs_webui.JUnit/dracula/dracula_graffle.js#18) (http://192.168.10.32:3692/com.gigaspaces.admin.webui.Gs_webui.JUnit/com.gigaspaces.admin.webui.Gs_webui.JUnit.nocache.js#16) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:601)
相关来源
这是使用的(非常简单)GWTTestCase
:
public class HistoryBrowserTest extends GWTTestCase {
@Override
public String getModuleName() {
return "com.gigaspaces.admin.webui.Gs_webui";
}
public void testHistoryBrowser() {
assertTrue(true);
}
}
依赖项/上下文信息
jUnit 4.10 用作外部 jar - 并被类路径成功引用,并且jUnit 模块不再像 GWT 团队指示的那样被继承 - 扩展.gwt.xml
文件从 GWT ( <inherits name="com.google.gwt.junit.JUnit" />
)继承 jUnitGWTTestCase
将自动继承它。
我Raphael-GWT
作为一个单独的模块使用。该模块也在主模块的.gwt.xml
文件中被引用,并且在所有其他情况下(开发/生产模式)运行良好。
我试过什么
- 简化案例,例如如上所示剥离测试案例。
- 验证部署描述符中的继承模块。
- 不同的 jUnit 版本,即在 V3 或 V4 下运行,并在每次更改时手动编译。
- 在谷歌上查找,以及在stackoverflow上查找,均无济于事。
更多相关信息
Raphael
lib 被用于我为 Dracula(一个 JS 图形可视化库)编写的 GWT 包装器,因此dracula_graffle.js
源自那里。附上.gwt.xml
文件来源供参考:
<module rename-to="gs_webui">
<inherits name="com.google.gwt.user.User" />
<!-- Other module inherits -->
<inherits name="com.extjs.gxt.ui.GXT" />
<inherits name="org.highchartsgwt.HighCharts" />
<inherits name="gwtupload.GWTUpload" />
<inherits name="com.hydro4ge.raphaelgwt.RaphaelGWT" />
<inherits name="com.gigaspaces.gauge.Gs_gauges" />
<inherits name="com.gigaspaces.graphs.Gs_graphs" />
<inherits name="com.gigaspaces.svgcomponents.Gs_svg_components" />
<inherits name="com.javaconstructors.colorpalette.Color_palette" />
<inherits name="com.gigaspaces.jquerywidgets.Gs_jquery_widgets" />
<inherits name="com.gigaspaces.codemirror_gwt.CodeMirror_GWT"/>
<inherits name="com.google.gwt.i18n.I18N"/>
<inherits name="com.google.gwt.query.Query" />
<!-- I18N stuff, log configurations, and so forth... -->
<entry-point class="com.gigaspaces.admin.webui.client.Gs_webui" />
<!-- further source folder inherits... -->
</module>