使用 Jenkins 和 Apache Ant 运行 QUnit 测试? [英] Running QUnit tests with Jenkins and Apache Ant?

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

问题描述

是否可以从 Jenkins 执行我的 QUnit (javascript) 单元测试?我的构建脚本是 Apache Ant.Jenkins 会将其作为单独的构建步骤执行,还是我需要在 Ant 构建脚本的配置中添加一些内容?

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?

推荐答案

所以,我终于想通了.

这是我的端到端实现:

  1. 安装 PhantomJS (http://phantomjs.org/) - 我在我的构建中安装了它/工具文件夹

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

安装 PhantomJS QUnit Runner 脚本 (https://gist.github.com/1588423) - 也安装在我的 build/tools 文件夹中

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

将以下目标添加到我的 build.xml 文件中:

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. 在我的 Jenkins 项目配置下,我现在使用minify qunit"调用 Ant

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

我将 Jenkins 指向 JUnit 样式的输出 XML 文件

I point Jenkins to the JUnit-style output XML file

而且,这是工作流程:

  1. 将更改检查到我的存储库中
  2. Jenkins 将轮询 GitHub 以了解更改
  3. 如有变动,Jenkins会拉下来
  4. Ant 将被调用,进行构建,然后运行我的单元测试
  5. 测试结果将以类似 JUnit 的 XML 格式发布
  6. Jenkins 将分析这个输出文件.如果没有测试失败,构建将被标记为成功".如果任何测试失败,构建将被标记为不稳定"
  7. Jenkins 将部署 Web 更改
  8. Jenkins 将清理工作区

PS:目前,您必须手动删除 JUnit 类型的 XML 输出文件.我稍后会解决这个问题.

PS: At the moment, you have to manually delete the JUnit-type XML output file. I will fix this later.

PS:下载定制的 qunit.js (https://gist.github.com/2488794)

PS: Download the customized qunit.js (https://gist.github.com/2488794)

这篇关于使用 Jenkins 和 Apache Ant 运行 QUnit 测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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