创建测试目录
1、在jenkins的workspace目录下创建测试工程的目录
cd /Users/developer/.jenkins/workspace
mkdir TuandaiFund_iOS_Tests
2、编写测试脚本,参考使用ruby编写测试用例
注意:appium.txt文件中app参数对应的值,指定为待测app的绝对路径
使用xcodebuild -workspace TuandaiFund.xcworkspace -sdk iphonesimulator11.2 -scheme TuandaiFund 查看这条命令输出的app目录,指定为这个地址即可
安装插件
打开jenkins->系统管理->管理插件->高级->上传cucumber-reports.hpi
![](https://img.haomeiwen.com/i1464430/af1606e437b20e24.png)
定时构建
配置触发器
打开jenkins新建一个自由风格的工程TuandaiFund_iOS_Tests
选择构建触发器->选择Build periodically,设置日程表为H 17 * * 1-5,表示每天下午5点构建
![](https://img.haomeiwen.com/i1464430/e47ea941c288e0d9.png)
配置脚本
# 进入jenkins的workspace目录
cd /Users/developer/.jenkins/workspace/TuandaiFund_iOS
# 编译工程生产app文件
xcodebuild -workspace TuandaiFund.xcworkspace -sdk iphonesimulator11.2 -scheme TuandaiFund
# 进入测试目录
cd /Users/developer/.jenkins/workspace/TuandaiFund_iOS_Tests/tests/ruby
# 按照ruby依赖库
bundle install
# 自动化测试并输出报表
cucumber --format json -o /Users/developer/.jenkins/workspace/TuandaiFund_iOS_Tests/report/cucumber.json
集成测试报告
1、选择增加构建后的操作->选择Cucumber reports
2、指定报告Json的路径
3、设置File Include Pattern为**/*.json
,使用正则匹配测试报告的json文件
![](https://img.haomeiwen.com/i1464430/0ca6ca2b61b957c6.png)
邮件通知
![](https://img.haomeiwen.com/i1464430/6dc45672f782ed0e.png)
报告示例
![](https://img.haomeiwen.com/i1464430/1bc2d52d998f0b1f.png)
![](https://img.haomeiwen.com/i1464430/9408a21d7f2c1cbe.png)
![](https://img.haomeiwen.com/i1464430/eeb1ac2e39c74910.png)
网友评论