3

我的项目是标准的 maven java 项目。我正在尝试将 jasmine-maven 插件包含到我的 CI 中。但是当我运行 command 时mvn clean install,它会正确运行测试。但是,如果我mvn jasmine:bdd从浏览器运行并运行测试。我的 html 装置未加载。

这是我的项目结构。


project
  |
  |-src
    |-main
    |-test
       |-java
          |-javascript
               |-jasmine
                    |-spec
                       |-spec.js
                       |-javascripts
                       |   |-fixtures
                       |       |-all_the_fixtures.html
                       |-lib
                          |-jasmine-jquery-1.3.1.js 


这是我的 pom.xml

  <plugin>
                    <groupId>com.github.searls</groupId>
                    <artifactId>jasmine-maven-plugin</artifactId>
                    <version>1.2.0.0</version>
                    <extensions>true</extensions>
                    <executions>
                        <execution>
                            <goals>
                                <goal>
                                 test
                                </goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <skipTests>false</skipTests>
                        <jsSrcDir>${basedir}/src/main/webapp/static/js</jsSrcDir>
                        <jsTestSrcDir>${basedir}/src/test/java/javascript/jasmine/spec</jsTestSrcDir>
                        <sourceIncludes>
                            <include>jquery/jquery-min.js</include>
                            <include>src/source.js</include>
                            <include>src/source1.js</include>
                        </sourceIncludes>
                        <specIncludes>
                            <include>lib/*.js</include>
                            <include>**/*.js</include>
                        </specIncludes>
                    </configuration>
                </plugin>

当我从浏览器运行测试时。所有的 html 固定装置都是 404。有没有办法让两种方式都起作用?

这就是我加载夹具的方式


it("should get content group with one breadcrumb", function() {
    loadFixtures("all_the_fixtures.html");
});

这是我的 jasmine-jquery 路径配置


  this.fixturesPath = 'spec/javascripts/fixtures/';

4

1 回答 1

1

我意识到这是一个老问题,只想在这里记录我的发现。我正在努力让一些相同的东西启动并运行自己。我发现运行 bdd 目标时路径是相对于项目的基础,而不是您创建的 jasmine 文件夹。这种结构可能会在 OP 的环境中工作。

project
|
|-spec
|  |-javascripts
|     |-fixtrues
|        |-all_the_fixtures.html
|-src
   |-main
   |-test
      |-java
      |-javascript
         |-jasmine
         |-spec
            |-spec.js
            |-javascripts
               |-lib
                  |-jasmine-jquery-1.3.1.js

据我所知,这是一个已知问题。

这是一篇关于如何使用配置文件解决它的帖子。基本上,您为 Jasmine 插件的每个目标创建一个配置文件。希望这可以帮助某人...

于 2015-01-22T21:28:30.663 回答