准备环境
1、安装pytest
pip install pytest -i http://pypi.douban.com/simple
pytest-ordering
pytest.main([
"-m login",
"-s", # 输出打印信息
""
])
2、安装pytest插件
官网翻译:https://www.jianshu.com/p/f3f13f2e6668
插件汇总:http://plugincompat.herokuapp.com/
pip install pytest-allure-adaptor -i http://pypi.douban.com/simple
3、安装allure
下载地址: https://github.com/allure-framework/allure2
压缩包:https://dl.bintray.com/qameta/maven/io/qameta/allure/allure-commandline/2.12.1/allure-commandline-2.12.1.zip
解压后将allure-2.12.1in目录添加到环境变量
验证
4、执行测试
查看用例目录
在APItesting目录下执行命令
pytest -s -q cases --alluredir reportsxml
-s 允许终端在测试运行时输出结果
-q 简化输出结果
-- alluredir 生成allure指定文件的语法
生产这样的文件
5、使用allure命令生成测试报告
allure generate reportsxml -o reports eport
reportsxml 这个目录是执行测试生成的数据-o reports eport 将测试报告输出保存到这个目录下
最终在report目录下生成以下文件和文件夹
最终在pycharm中打开index.html文件,就可以看到测试报告
参考链接:
https://www.cnblogs.com/hao2018/p/9915044.html
https://www.cnblogs.com/xiaoxi-3-/p/9492534.html