Python+Appium+Pytest+Allure实战APP自动化测试
pytest只是单独的一个单元测试框架,要完成app测试自动化需要把pytest和appium进行整合,同时利用allure完成测试报告的产出。
编写常规的线性脚本具体的步骤如下:
1、设计待测试APP的自动化测试用例
2、新建app测试项目
3、配置conftest.py文件等
4、编写整体app测试用例运行文件
5、把设计好的自动化测试用例转化成脚本备注:
为了保证脚本的稳定性,又把pytest常用功能应用,以下示例采用android计算器为示例讲解。
Gitee上完整代码:https://gitee.com/YouJeffrey/AUTO_TEST_APP
前置条件:下载第三方库
1、下载 appium-python-client
2、下载pytest
3、下载 allure-pytest
一、设计待测试APP的自动化测试用例
二、新建APP测试项目
三、配置文件信息
1、先配置外层conftest.py文件
import pytest # 配置app的各种连接信息 @pytest.fixture(scope='session') def android_setting(): des = { 'automationName': 'appium', 'platformName': 'Android', 'platformVersion': '6.0.1', # 填写android虚拟机/真机的系统版本号 'deviceName': 'MuMu', # 填写安卓虚拟机/真机的设备名称 'appPackage': 'com.sky.jisuanji', # 填写被测app包名 'appActivity': '.JisuanjizixieActivity', # 填写被测app的入口 'udid': '127.0.0.1:7555', # 填写通过命令行 adb devices 查看到的udid 'noReset': True, # 是否重置APP 'noSign': True, # 是否不签名 'unicodeKeyboard': True, # 是否支持中文输入 'resetKeyboard': True, # 是否支持重置键盘 'newCommandTimeout': 30 # 30秒没发送新命令就断开连接 } return des