moh*_*hit 43 continuous-integration selenium jenkins protractor
我正在使用Protractor编写自动化测试脚本,现在我需要使用Jenkins为此设置CI.
它需要执行的任务是:
任何人都可以帮助这方面吗?
gon*_*ard 38
我创建了一个小的bash脚本来执行此操作.
# 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
Run Code Online (Sandbox Code Playgroud)
这个脚本是从jenkins 的自由风格项目中调用的(Build > Execute shell)

然后通过读取量角器测试结果生成测试结果报告.因此,你必须从量角器生成junit报告,(看这里):
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));
},
Run Code Online (Sandbox Code Playgroud)
为了使报告在jenkins中可见,我在作业中添加了一个帖子构建操作Publish JUnit test result report:

Jac*_*ltz 12
或者,您可以将其作为Grunt任务运行.首先在Jenkins上安装grunt.安装protractor_webdriver和量角器的NPM包.设置配置文件以指向node_module路径和配置文件路径.
http://sideroad.secret.jp/articles/grunt-on-jenkins/
然后安装量角器节点模块.Gruntfile看起来与此类似.我创建了一个测试目录,其中包含conf和spec文件.
module.exports = function (grunt) {
grunt.initConfig({
protractor_webdriver: {
your_target: {
options: {
path: 'node_modules/protractor/bin/',
command: 'webdriver-manager start'
}
}
},
protractor: {
options: {
configFile: "node_modules/protractor/referenceConf.js", // Default config file
keepAlive: true, // If false, the grunt process stops when the test fails.
noColor: false, // If true, protractor will not use colors in its output.
args: {
// Arguments passed to the command
}
},
your_target: {
options: {
configFile: "test/conf.js", // Target-specific config file
args: {} // Target-specific arguments
}
}
}
});
grunt.registerTask('p:test', [
'protractor_webdriver',
'protractor'
]);
});
Run Code Online (Sandbox Code Playgroud)
最新的量角器允许您直接从conf.js(或您拥有的任何量角器入口点)运行selenium独立服务器.
注释掉(或删除)该seleniumAddress: 'http://localhost:4444/wd/hub',行,并将其替换为seleniumServerJar: './node_modules/protractor/selenium/latest.jar'.
latest.jar默认情况下未安装,我将其创建为通过安装的最新版本的符号链接npm install protractor --save.这样可以延长conf.js同一目录中文件的使用寿命.在./node_modules/protractor/selenium/我运行的文件夹中ln -s selenium-server-standalone-2.48.2.jar latest.jar
| 归档时间: |
|
| 查看次数: |
46568 次 |
| 最近记录: |