使用 Jenkins 设置量角器的持续集成 [英] Setting up Continuous Integration of Protractor using Jenkins
问题描述
我正在使用 Protractor 编写自动化测试脚本,现在我需要使用 Jenkins 为此设置 CI.
I am writing automation test scripts using Protractor and now I need to set up the CI for this using Jenkins.
它需要执行的任务是:
- 启动 selenium 独立服务器.
- 使用 conf.js 文件开始测试.
- 停止 selenium 独立服务器.
任何人都可以在这方面提供帮助吗?
Can anyone help in this regard?
推荐答案
我创建了一个小的 bash 脚本 来执行此操作.
I created a small bash script to do this.
# start selenium
./node_modules/protractor/bin/webdriver-manager start > /dev/null 2>&1 &
# wait until selenium is up
while ! curl http://localhost:4444/wd/hub/status &>/dev/null; do :; done
# run the build
grunt cibuild --force
# stop selenium
curl -s -L http://localhost:4444/selenium-server/driver?cmd=shutDownSeleniumServer > /dev/null 2>&1
这个脚本是从 jenkins 中的一个自由风格的项目调用的(Build > Execute shell)
This script is invoked from a free-style project in jenkins (Build > Execute shell)
然后通过读取量角器测试结果生成测试结果报告.因此,您必须从量角器生成 junit 报告,(看 这里) :
Then the test result report is generated by reading the protractor test results. Hence, you have to produce junit reports from protractor, (look here) :
onPrepare: function() {
// The require statement must be down here, since jasmine-reporters
// needs jasmine to be in the global and protractor does not guarantee
// this until inside the onPrepare function.
require('jasmine-reporters');
jasmine.getEnv().addReporter(
new jasmine.JUnitXmlReporter('xmloutput', true, true));
},
为了使报告在 jenkins 中可见,我在作业中添加了一个构建后操作:Publish JUnit test result report
:
To make the report visible in jenkins i add a post build action in the job: Publish JUnit test result report
:
这篇关于使用 Jenkins 设置量角器的持续集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!