是否可以从 Jenkins 执行我的 QUnit (javascript) 单元测试?我的构建脚本是 Apache Ant。 Jenkins 会将其作为单独的构建步骤执行,还是我需要在我的 Ant 构建脚本的配置中添加一些内容?
最佳答案
所以,我终于设法弄清楚了。
这是我的端到端实现:
安装 PhantomJS (http://phantomjs.org/) - 我将它安装在我的 build/tools 文件夹中
安装 PhantomJS QUnit Runner 脚本 (https://gist.github.com/1588423) - 也将它安装在我的 build/tools 文件夹中
在我的 build.xml 文件中添加了以下目标:
<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>
在我的 Jenkins 项目配置下,我现在使用“minify qunit”调用 Ant
我将 Jenkins 指向 JUnit 样式的输出 XML 文件
还有,这是工作流程:
PS:目前,您必须手动删除 JUnit 类型的 XML 输出文件。我稍后会解决这个问题。
PS:下载自定义的 qunit.js (https://gist.github.com/2488794)
https://stackoverflow.com/questions/10275476/