在使用jasmine-maven-plugin运行Jasmine测试时,我经常收到以下错误,在我们的应用程序中加载javascript内部错误。这似乎只发生在我们的CI环境(Jenkins)中,并且每次运行测试时都不会发生。我已经验证Jetty已启动并正在侦听指定的端口。
之前有没有遇到过这个?如果是这样,是否有稳定构建的解决方案?
插件配置:
<groupId>com.github.searls</groupId>
<artifactId>jasmine-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
<configuration>
<debug>true</debug>
<!-- Instruct plugin on where to find our require.js -->
<specRunnerTemplate>REQUIRE_JS</specRunnerTemplate>
<!-- Location of the JS source -->
<jsSrcDir>${project.basedir}/src/main/webapp/web3/js</jsSrcDir>
<!-- Location of the Jasmine Specs -->
<jsTestSrcDir>${project.basedir}/src/test/javascript</jsTestSrcDir>
<preloadSources>
<source>vendor/require-2.1.9.js</source>
<source>vendor/jquery-1.4.2.min.js</source>
<source>utils/jasmine.extensions.js</source>
<!-- Load the require.js config file. By default, jasmine-maven-plugin looks for require.js if not set by deprecated scriptLoaderPath property. -->
<source>main.js</source>
</preloadSources>
<haltOnFailure>false</haltOnFailure>
</configuration>
</plugin>
错误:
[INFO]
[INFO] --- jasmine-maven-plugin:1.3.1.3:test (default) @ collaterate-pub ---
2013-12-31 10:52:34.521:INFO:oejs.Server:jetty-8.1.13.v20130916
2013-12-31 10:52:34.557:INFO:oejs.AbstractConnector:Started SelectChannelConnector@0.0.0.0:38921
[INFO] Executing Jasmine Specs
Dec 31, 2013 10:52:39 AM com.gargoylesoftware.htmlunit.html.HtmlPage loadExternalJavaScriptFile
SEVERE: Error loading JavaScript from [http://localhost:38921/web3/js/vendor/knockout-3.0.0.js].
java.io.IOException: Unable to download JavaScript from 'http://localhost:38921/web3/js/vendor/knockout-3.0.0.js' (status 404).
at com.gargoylesoftware.htmlunit.html.HtmlPage.loadJavaScriptFromUrl(HtmlPage.java:1125)
at com.gargoylesoftware.htmlunit.html.HtmlPage.loadExternalJavaScriptFile(HtmlPage.java:1059)
at com.gargoylesoftware.htmlunit.html.HtmlScript.executeScriptIfNeeded(HtmlScript.java:399)
at com.gargoylesoftware.htmlunit.html.HtmlScript$3.execute(HtmlScript.java:266)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.doProcessPostponedActions(JavaScriptEngine.java:714)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.access$500(JavaScriptEngine.java:91)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:664)
at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:601)
at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:507)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:601)
at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:576)
at com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptFunctionIfPossible(HtmlPage.java:1005)
at com.gargoylesoftware.htmlunit.javascript.background.JavaScriptFunctionJob.runJavaScript(JavaScriptFunctionJob.java:53)
at com.gargoylesoftware.htmlunit.javascript.background.JavaScriptExecutionJob.run(JavaScriptExecutionJob.java:101)
at com.gargoylesoftware.htmlunit.javascript.background.JavaScriptJobManagerImpl.runSingleJob(JavaScriptJobManagerImpl.java:328)
at com.gargoylesoftware.htmlunit.javascript.background.DefaultJavaScriptExecutor.run(DefaultJavaScriptExecutor.java:162)
at java.lang.Thread.run(Thread.java:662)