mac终端使用pytest执行iOS UI自动化测试方法

1、安装pytest-repeat插件:

pip install pytest-repeat

2、安装allure-pytest插件:

pip install allure-pytest

3、打开终端:

pytest -q -s -ra --count=100 test_open_stream.py --alluredir=./report/CXL

-q:表示"quiet mode"(安静模式),减少输出信息,只显示最小的结果信息。

-s:允许在控制台中输出 print 语句的内容,方便调试。

-ra:显示测试报告摘要,包括通过、失败、错误等详细信息。

--count=100:表示将 test_open_stream.py 测试运行 100 次。

--alluredir=./report/C6L:将测试结果保存到 ./report/CXL 目录中,以便之后生成 Allure 报告。

4、在测试完成后,生成 Allure 报告来查看详细的测试结果:

allure serve ./report/CXL

在查看报告之前需要安装allure插件:

brew install allure

查看是否安装成功:

allure --version

【问题】

allure安装时间较长,需要网络稳定,第一次没有安装成功。第二次安装allure过程出现如下报错:

==> Pouring python@3.12--3.12.7_1.sonoma.bottle.tar.gz Error: The brew link step did not complete successfully The formula built, but is not symlinked into /usr/local Could not symlink bin/2to3-3.12 Target /usr/local/bin/2to3-3.12 already exists. You may want to remove it: rm '/usr/local/bin/2to3-3.12' To force the link and overwrite all conflicting files: brew link --overwrite python@3.12 To list all files that would be deleted: brew link --overwrite python@3.12 --dry-run Possible conflicting files are: /usr/local/bin/2to3-3.12 -> /Library/Frameworks/Python.framework/Versions/3.12/bin/2to3-3.12 /usr/local/bin/idle3.12 -> /Library/Frameworks/Python.framework/Versions/3.12/bin/idle3.12 /usr/local/bin/pydoc3.12 -> /Library/Frameworks/Python.framework/Versions/3.12/bin/pydoc3.12 /usr/local/bin/python3.12 -> /Library/Frameworks/Python.framework/Versions/3.12/bin/python3.12 /usr/local/bin/python3.12-config -> /Library/Frameworks/Python.framework/Versions/3.12/bin/python3.12-config

【解决】

rm /usr/local/bin/2to3-3.12

rm /usr/local/bin/idle3.12

rm /usr/local/bin/pydoc3.12

rm /usr/local/bin/python3.12

rm /usr/local/bin/python3.12-config

brew link python@3.12

【备注】

上面的报错原因是我之前安装的python版本不是通过homebrew安装的,在后续使用homebrew安装其他插件时会弹出上面的提示,即homebrew希望有它来管理python版本。按照上面的解决方法,可以解决问题,但是后来在使用pytest执行脚本的时候报错:

testmanzhang@TestMandeMBP practiceUICatalog % pytest

Traceback (most recent call last):

File "/Library/Frameworks/Python.framework/Versions/3.12/bin/pytest", line 5, in <module>

from pytest import console_main

之前安装的pytest插件不能用了,后来恢复了原来的符号连接:

sudo rm /usr/local/bin/2to3-3.12

sudo ln -s /Library/Frameworks/Python.framework/Versions/3.12/bin/2to3-3.12 /usr/local/bin/2to3-3.12

sudo rm /usr/local/bin/idle3.12

sudo ln -s /Library/Frameworks/Python.framework/Versions/3.12/bin/idle3.12 /usr/local/bin/idle3.12

sudo rm /usr/local/bin/pydoc3.12

sudo ln -s /Library/Frameworks/Python.framework/Versions/3.12/bin/pydoc3.12 /usr/local/bin/pydoc3.12

sudo rm /usr/local/bin/python3.12

sudo ln -s /Library/Frameworks/Python.framework/Versions/3.12/bin/python3.12 /usr/local/bin/python3.12

sudo rm /usr/local/bin/python3.12-config

sudo ln -s /Library/Frameworks/Python.framework/Versions/3.12/bin/python3.12-config /usr/local/bin/python3.12-config

所以建议大家使用homebrew安装python。

相关推荐
天庭鸡腿哥31 分钟前
国外软件,安装即时专业版!
stm32·microsoft·macos·everything
给你一页白纸7 小时前
Pytest 测试用例自动生成:接口自动化进阶实践
python·pytest·接口自动化
appleyk9 小时前
MacOS-12(Intel) Docker部署Dify1.11.1
macos·docker·agent·dify·dify部署
工会主席-阿冰9 小时前
使用pytest-selenium插件,ui自动化示例
selenium·pytest
风为你而吹10 小时前
mac m3上使用vscode + platformio开发esp32
ide·vscode·macos
工会主席-阿冰10 小时前
pytest,ui自动化示例
pytest·ui自动化
想做后端的小C11 小时前
Mac 环境下设置 idea 中的 tomcat 运行配置
macos·tomcat·intellij-idea
转战英雄枫1 天前
Mac上打开安卓虚拟机BlueStacks Air闪退问题解决
macos·bluestacks
liliangcsdn1 天前
mac m1安装homebrew和iterm2示例
macos
墨&白.1 天前
如何卸载/更新Mac上的R版本
开发语言·macos·r语言