【问题标题】:How to integrate Jasmine with Maven如何将 Jasmine 与 Maven 集成
【发布时间】:2013-07-29 16:17:04
【问题描述】:

我正在尝试配置 jasmine-maven-plugin。

我的项目结构如下:

Root
 | --Sub peoject-1 (Common)
 |    |--src
 |    |   |--main
 |    |   |   |--java
 |    |   |   |--resources
 |    |   |   |--webapp
 |    |   |     |--js
 |    |   |     |--<Jquery library> 
 |    |   |--test
 |    |       |--jasmine
 |    |         |--css
 |    |         |--js
 |    |             |--<Jasmine library>
 |    |             |--jasmineSpecRunner.js
 |    |--pom.xml
 |--Sub peoject-2 (JAR project)
 |    |--src
 |    |   |--main
 |    |   |   |--java
 |    |   |   |--resources
 |    |   |--test
 |    |       |--jasmine
 |    |       |--css
 |    |--pom.xml
 |--Sub peoject-3
 |    |--src
 |    |  |--main
 |    |  |    |--java
 |    |  |    |--resources
 |    |  |    |--webapp
 |    |  |         |--js
 |    |  |--test
 |    |      |--jasmine
 |    |           |--html
 |    |           |   |--moduleSpecificSpecRunner.html
 |    |           |--js
 |    |               |--moduleSpecificJasmineSpecification.js
 |    |--pom.xml
 |--pom.xml

我将所有常见的 JavaScript 文件与 jasmineSpecRunner javascript(Jasmine 引擎)一起保存在 Common web 项目中(即 jQuery 库文件、Jasmine 库文件等)。

在模块特定的 specRunner javascript (moduleSpecificJasmineSpecification.js) 中,我包含了所有常见的 javascript 文件、模块特定的 javascript 源文件和 jasmineSpecRunner javascript(Jasmine 引擎)。

我在 test/jasmine 文件夹中编写了一些 jasmine 测试用例,我正在尝试配置 jasmine-maven-plugin。在模块特定的 pom 文件中,我包含了以下标签:

<plugin>
    <groupId>com.github.searls</groupId>
    <artifactId>jasmine-maven-plugin</artifactId>
    <version>1.3.1.1</version>
    <extensions>true</extensions>
    <executions>
        <execution>
            <goals>
                <goal>test</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <jsSrcDir>${project.basedir}/src/main/webapp/js</jsSrcDir>
        <jsTestSrcDir>${project.basedir}/src/test/jasmine/js</jsTestSrcDir>
    </configuration>
</plugin>

在标记下的根 pom 文件中,我添加了以下条目:

<plugin>
    <groupId>com.github.searls</groupId>
    <artifactId>jasmine-maven-plugin</artifactId>
    <version>1.3.1.1</version>
    <extensions>true</extensions>
</plugin>

但在执行mvn jasmine:bdd 命令后,我无法在http://localhost:8234 url 中查看jasmine 测试输出。

我认为配置不正确。

谁能帮我为上述项目结构配置 jasmine-maven-plugin?谢谢!

【问题讨论】:

  • 你知道如何设置 Maven / jasmine 吗?我正在尝试做同样的事情并卡住了一堵墙。谢谢杰
  • 在您的浏览器中,尝试探索 localhost:8234/src 路径。这显示了 phantomjs 提供的文件。可能不会提供您的依赖项(常见)中的文件。我也在寻找解决方案...

标签: maven jasmine


【解决方案1】:

我以这种方式配置它并且它为我工作

 <plugin>
            <groupId>com.github.searls</groupId>
            <artifactId>jasmine-maven-plugin</artifactId>
            <version>2.2</version>
            <executions>
                <execution>
                    <goals>
                        <goal>test</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <skipJasmineTests>${js-tests.skip}</skipJasmineTests>
                <webDriverClassName>org.openqa.selenium.phantomjs.PhantomJSDriver</webDriverClassName>
                <!--<webDriverCapabilities>
                  <capability>
                    <name>phantomjs.binary.path</name>
                    <value>${project.basedir}/target/phantomjs-maven-plugin/phantomjs-2.1.1-linux-x86_64/bin/phantomjs</value>
                  </capability>
                </webDriverCapabilities>-->
                <jsSrcDir>${project.basedir}/src/main/webapp</jsSrcDir>
                <jsTestSrcDir>${project.basedir}/src/main/webapp/tests/spec</jsTestSrcDir>
                <preloadSources>
                    <source>${project.basedir}/src/main/webapp/libs/vendor/jquery-latest.min.js</source>
                    <source>${project.basedir}/src/main/webapp/libs/vendor/angular.min.js</source>
                    <source>${project.basedir}/src/main/webapp/libs/vendor/angular-mocks.js</source>
                    <source>${project.basedir}/src/main/webapp/libs/vendor/angular-resource.js</source>
                    <source>${project.basedir}/src/main/webapp/libs/vendor/jasmine-jquery.js</source>
                    <source>${project.basedir}/src/main/webapp/app/app.js</source>
                </preloadSources>
                <sourceIncludes>
                  <include>${project.basedir}/src/main/webapp/*.js</include>
                </sourceIncludes>
            </configuration>
        </plugin>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-02
    • 1970-01-01
    • 2015-02-24
    • 2014-11-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多