减少错误和手动任务
及早发现并解决集成挑战
更短的交付周期
被测代码(存放于代码仓)
Jenkins节点机器以及运行环境
博客地址:https://blog.csdn.net/YZL40514131/article/details/130142810?spm=1001.2014.3001.5501
当前项目在windows节点跑,所以需要在windows中配置各种环境变量
C:\Users\Lenovo>java -version java version "11.0.18" 2023-01-17 LTS Java(TM) SE Runtime Environment 18.9 (build 11.0.18+9-LTS-195) Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.18+9-LTS-195, mixed mode)
Chrome 浏览器和chromedriver要匹配
C:\Users\Lenovo>where chromedriver D:\chromedriver\chromedriver.exe C:\Program Files\Google\Chrome\Application\chromedriver.exe C:\Users\Lenovo>chromedriver Starting ChromeDriver 110.0.5481.30 (aedb656755c469651f01505a4f15e153fc606a1e-refs/branch-heads/5481@{#191}) on port 9515 Only local connections are allowed. Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe. ChromeDriver was started successfully.
C:\Users\Lenovo>python Python 3.9.6 (tags/v3.9.6:db3ff76, Jun 28 2021, 15:26:21) [MSC v.1929 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information.
C:\Users\Lenovo>where allure D:\allure-commandline-2.13.2\allure-2.13.2\bin\allure D:\allure-commandline-2.13.2\allure-2.13.2\bin\allure.bat
Pycharm拉取代码执行
命令行运行代码,并生成报告
pip freeze > requirements.txt
指定windows节点运行UI自动化,linux不适合运行UI自动化,linux需要安装浏览器,而且运行脚本是没有界面的,运行UI自动化只能通过无头模式运行
创建节点(需要保证远程工作目录是存在的)
call auto_env\Scripts\activate 激活虚拟环境 #给虚拟环境安装依赖 pip install -r requirements.txt #运行脚本 python -m pytest --alluredir=./results --clean-alluredir
allure报告设置相对路径设置
与 python -m pytest --alluredir=./results --clean-alluredir 中的results一致
特别注意:还需要在运行节点—>配置从节点—>节点属性
勾选工具位置,设置Allure Commandline的目录(可以通过C:\Users\Lenovo>where allure查)