运行与詹金斯和Apache Ant QUnit测试? [英] Running QUnit tests with Jenkins and Apache Ant?
问题描述
是否有可能从詹金斯执行我的QUnit(JavaScript)的单元测试?我的构建脚本是Apache Ant的。詹金斯将执行此作为一个单独的生成步骤,或者我需要在我的Ant构建脚本的配置添加的东西?
所以,我终于设法想出解决办法。
下面是我的终端到终端的实现:
-
安装PhantomJS( http://phantomjs.org/ ) - 我在编译/工具文件夹中安装此
-
安装PhantomJS QUnit亚军脚本( https://gist.github.com/1588423 ) - 也安装这在我的构建/ tools文件夹
-
增加了以下目标到我的build.xml文件:
<目标名称=qunit描述=使用PhantomJS运行QUnit测试>
<! - QUnit的JavaScript单元测试 - >
<回声消息=执行QUnit的JavaScript单元测试.../>
<申请执行=路径到您的-phantomjs斌文件夹/ phantomjs>
< ARG值= - 路径到您的构建工具/ qunit-runner.js/>
< ARG行= - qunit路径到您的-qunit文件夹/ qunit.js --tests路径到您的测试文件夹--juni路径,其中任您想对写的-JUnit式输出/ qunit-results.xml/>
<文件集DIR =$ {BASEDIR} / $ {} dir.test包括=tests.js/>
< SRCFILE />
< /应用>
< /目标与GT;
-
在我的詹金斯项目配置,我现在用缩小qunit
调用Ant -
我点詹金斯JUnit的风格输出XML文件
和,这里是工作流程:
- 检查变成我的回购
- 詹金斯将轮询GitHub的更改
- 如果有任何变化,詹金斯将拉低
- 蚂蚁将被调用,做构建,然后运行我的单元测试
- 测试结果将公布在一个JUnit般的XML格式
- 詹金斯将分析该输出文件。如果没有测试失败,生成将被标记为成功。如果任何测试失败,生成将被标记为不稳定
- 詹金斯将部署在网络的变化
- 詹金斯将清理工作区域
PS:目前,你必须手动删除了JUnit型XML输出文件。稍后我会解决这个问题。
PS:下载定制qunit.js( https://gist.github.com/2488794 )
Is it possible to execute my QUnit (javascript) unit tests from Jenkins? My build script is Apache Ant. Would Jenkins execute this as a separate Build Step, or would I need to add something in the config of my Ant build script?
So, I have finally managed to figure this out.
Here's my end-to-end implementation:
Install PhantomJS (http://phantomjs.org/) - I installed this in my build/tools folder
Install the PhantomJS QUnit Runner script (https://gist.github.com/1588423) - also installed this in my build/tools folder
Added the following target to my build.xml file:
<target name="qunit" description="runs QUnit tests using PhantomJS">
<!-- QUnit Javascript Unit Tests -->
<echo message="Executing QUnit Javascript Unit Tests..."/>
<apply executable="path-to-your-phantomjs-bin-folder/phantomjs" >
<arg value="-path-to-your-build-tools/qunit-runner.js" />
<arg line="--qunit path-to-your-qunit-folder/qunit.js --tests path-to-your-test-folder --juni path-where-you-want-to-write-the-JUnit-style-output/qunit-results.xml" />
<fileset dir="${basedir}/${dir.test}" includes="tests.js" />
<srcfile/>
</apply>
</target>
Under my Jenkins project config, I now invoke Ant with "minify qunit"
I point Jenkins to the JUnit-style output XML file
And, here is the workflow:
- Check changes into my repo
- Jenkins will poll GitHub for changes
- If there are any changes, Jenkins will pull down
- Ant will be invoked, doing the build, then running my unit tests
- The test results will be published in a JUnit-like XML format
- Jenkins will analyse this output file. If no tests failed, the build will be marked as "Success". If any tests failed, the build will be marked as "Unstable"
- Jenkins will deploy the web changes
- Jenkins will cleanup the work-area
PS: At the moment, you have to manually delete the JUnit-type XML output file. I will fix this later.
PS: Download the customized qunit.js (https://gist.github.com/2488794)
这篇关于运行与詹金斯和Apache Ant QUnit测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!