Mat*_*att 16 qunit maven phantomjs
我一直在调查在maven CI环境中进行JS单元测试的最佳方法.我目前拼凑的是我的maven项目中的以下内容:
更改为pom.xml以在构建的测试阶段运行phantomjs测试:
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<id>PhantomJS Unit Testing</id>
<phase>test</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>${project.basedir}/src/main/webapp/unittest/phantomcheck</executable>
<arguments>
<argument>${project.basedir}/src/main/webapp/unittest/qunit-runner.js</argument>
<argument>${project.basedir}/src/main/webapp/unittest/tests/index.html</argument>
<argument>${project.build.directory}/surefire-reports</argument>
</arguments>
</configuration>
</plugin>
</plugins>
Run Code Online (Sandbox Code Playgroud)所以,这很好用.它在我们的开发和构建机器上构建时运行qunit测试(只要安装了PhantomJS).测试在无头浏览器环境中运行,对qunit测试没有限制.我见过的其他maven/qunit集成由于在Rhino中运行测试或其他对我们可以编写的测试类型进行限制的JS环境而无法实现.加上phantomjs使我们能够获得测试运行的屏幕截图,这有助于排除任何故障.
我的方法的缺点是在构建/开发机器上需要安装PhantomJS.我不知道如何将phantomJS捆绑到依赖项中,以便开发人员不必担心安装PhantomJS.任何人都可以向我推动这个方向吗?我该如何开始?
该phantomjs - Maven的插件提供了一个install用于安装phantomjs,所以你不需要它预装根本目标.安装phantomjs之后,它会设置一个属性,其中包含可执行文件的路径,然后其他插件可以使用.它还有一个exec执行phantomjs脚本的目标.完全披露:我写了插件.
| 归档时间: |
|
| 查看次数: |
10803 次 |
| 最近记录: |