运行与詹金斯和Apache Ant QUnit测试? [英] Running QUnit tests with Jenkins and Apache Ant?

查看:176
本文介绍了运行与詹金斯和Apache Ant QUnit测试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能从詹金斯执行我的QUnit(JavaScript)的单元测试?我的构建脚本是Apache Ant的。詹金斯将执行此作为一个单独的生成步骤,或者我需要在我的Ant构建脚本的配置添加的东西?


解决方案

所以,我终于设法想出解决办法。

下面是我的终端到终端的实现:


  1. 安装PhantomJS( http://phantomjs.org/ ) - 我在编译/工具文件夹中安装此


  2. 安装PhantomJS QUnit亚军脚本( https://gist.github.com/1588423 ) - 也安装这在我的构建/ tools文件夹


  3. 增加了以下目标到我的build.xml文件:


<目标名称=qunit描述=使用PhantomJS运行QUnit测试>
      <! - QUnit的JavaScript单元测试 - >
      <回声消息=执行QUnit的JavaScript单元测试.../>
      <申请执行=路径到您的-phantomjs斌文件夹/ p​​hantomjs>
        < ARG值= - 路径到您的构建工具/ qunit-runner.js/>
        < ARG行= - qunit路径到您的-qunit文件夹/ qunit.js --tests路径到您的测试文件夹--juni路径,其中任您想对写的-JUnit式输出/ qunit-results.xml/>
        <文件集DIR =$ {BASEDIR} / $ {} dir.test包括=tests.js/>
        < SRCFILE />
      < /应用>
    < /目标与GT;


  1. 在我的詹金斯项目配置,我现在用缩小qunit

  2. 调用Ant
  3. 我点詹金斯JUnit的风格输出XML文件


和,这里是工作流程:


  1. 检查变成我的回购

  2. 詹金斯将轮询GitHub的更改

  3. 如果有任何变化,詹金斯将拉低

  4. 蚂蚁将被调用,做构建,然后运行我的单元测试

  5. 测试结果将公布在一个JUnit般的XML格式

  6. 詹金斯将分析该输出文件。如果没有测试失败,生成将被标记为成功。如果任何测试失败,生成将被标记为不稳定

  7. 詹金斯将部署在网络的变化

  8. 詹金斯将清理工作区域

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:

  1. Install PhantomJS (http://phantomjs.org/) - I installed this in my build/tools folder

  2. Install the PhantomJS QUnit Runner script (https://gist.github.com/1588423) - also installed this in my build/tools folder

  3. 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>

  1. Under my Jenkins project config, I now invoke Ant with "minify qunit"

  2. I point Jenkins to the JUnit-style output XML file

And, here is the workflow:

  1. Check changes into my repo
  2. Jenkins will poll GitHub for changes
  3. If there are any changes, Jenkins will pull down
  4. Ant will be invoked, doing the build, then running my unit tests
  5. The test results will be published in a JUnit-like XML format
  6. 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"
  7. Jenkins will deploy the web changes
  8. 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆