近期用Pytest+Appium搭建App自动化,报告用Allure生成,期间遇到一些问题,记录下
pytest.main 执行的时候,拉不到对应的case
原因:测试class不是Test开头。要求文件名、类、测试方法,都以test开头
生成的allure报告,mac本地无法预览
解决方案:在html目录起本地http服务
sudo npm install http-server -global
cd /Users/zmfflying/Desktop/dist
http-server -p8000
转自:https://www.jianshu.com/p/f03c4d35ebf6
与allure结合执行
if __name__ == "__main__":
pytest.main([__file__, '-s', '-v', "--alluredir", "./report/result"])
os.system("allure generate ./report/result -o ./report/html --clean")
截图&加入allure报告
allure.attach(self.driver.get_screenshot_as_png(), 'result file', allure.attachment_type.PNG)
apk安装
在desired_caps指定app;或者用adb命令(adb相对稳定)
desired_caps['app'] = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) + '/file/test.apk'
执行结束-apk卸载
在desired_caps指定app;或者用adb命令
desired_caps['fullReset'] = True
失败重复执行
1.安装依赖:pip install pytest-rerunfailures
2.在pytest.main命令行中添加 --reruns=2
---
开心工作,认真生活;回望来时路,脚印三两,笑声无数...
开心工作,认真生活;回望来时路,脚印三两,笑声无数...