【发布时间】:2012-03-28 09:31:46
【问题描述】:
我正在使用 require-js 对我的 java 脚本项目中的依赖项进行建模。我还使用 jasmine 编写 BDD 样式的测试用例,并使用 jasmine-maven-plugin:1.1.0 以无头模式执行这些测试。
这是我的源项目结构
project/
| src/main/javascript
| | api/*.js
| | main.js
| src/test/javascript
| | spec/*spec.js
这是我的 webapp pom jasmine 配置:
<plugin>
<groupId>com.github.searls</groupId>
<artifactId>jasmine-maven-plugin</artifactId>
<version>1.1.0</version>
<executions>
<execution>
<goals>
<goal>generateManualRunner</goal>
<goal>resources</goal>
<goal>testResources</goal>
<goal>test</goal>
<goal>preparePackage</goal>
</goals>
</execution>
</executions>
<configuration>
<specRunnerTemplate>REQUIRE_JS</specRunnerTemplate>
<scriptLoaderPath>lib/require-jquery.js</scriptLoaderPath>
<sourceIncludes>
<include>lib/require-jquery.js</include>
<include>lib/underscore.js</include>
<include>lib/backbone.js</include>
<include>lib/d3.js</include>
<include>lib/d3.layout.js</include>
<include>lib/bootstrap.js</include>
<include>main.js</include>
</sourceIncludes>
<preloadSources>
<source>lib/require-jquery.js</source>
<source>lib/underscore.js</source>
<source>lib/backbone.js</source>
<source>lib/d3.js</source>
<source>lib/d3.layout.js</source>
<source>lib/bootstrap.js</source>
<source>main.js</source>
</preloadSources>
<browserVersion>FIREFOX_3_6</browserVersion>
</configuration>
</plugin>
在 maven 构建期间,所有 js 源都被复制到 target/jasmine/src。引用我的 main.js 的 runner.html 位于 target/jasmine。
现在的问题是我的 require-js 模块定义了它们相对于 main.js 的依赖关系,而在 maven 测试运行中,运行器假定它们是相对于 target/jasmine/runner.html 的。由于我的模块不(也一定不)知道额外的 jasmine/src 文件夹,恕我直言,这是一个问题。
我在运行 mvn clean install 时收到以下错误消息:
未能执行目标 com.github.searls:jasmine-maven-plugin:1.1.0:test(默认)在项目上 mywebapp:jasmine-maven-plugin 遇到了一个 异常:java.lang.RuntimeException: org.openqa.selenium.WebDriverException: com.gargoylesoftware.htmlunit.ScriptException: Wrapped com.gargoylesoftware.htmlunit.ScriptException: Wrapped com.gargoylesoftware.htmlunit.ScriptException: Wrapped com.gargoylesoftware.htmlunit.ScriptException: Wrapped com.gargoylesoftware.htmlunit.ScriptException: Wrapped java.lang.RuntimeException:java.io.FileNotFoundException: C:\Jenkins\jobs\job1\workspace\mywebapp\target\jasmine\api\data-util.js (系统找不到指定的路径)
有人有想法解决或配置它吗?
【问题讨论】:
标签: javascript maven requirejs jasmine