web自动化07-pytest01

1、框架包含的内容

  1. 编写用例
  2. 收集用例-筛选用例-用例标记markers
  3. 运行用例
  4. 生成报告
  5. 数据驱动-web自动化用的少
  6. 前置后置
  7. 插件系统 :
    • 失败重运行
    • aliure测试报告
    • 并发执行

2、pytest安装

3、终端运行pytest

 4、为什么用pytest

 5、使用pytest设置

6、编写测试用例的方法

7、收集用例pytest和unittest的区别

pytest自动收集,unittest需要运行程序,比如说discover等代码

8、运行用例的三种方式

  • 单个用例执行,直接def 函数上运行
  • 终端运行,输入pytest
  • 编写函数,运行pytest,main()函数

9、生成报告

setting -类似pytest安装,搜索pytest,安装pytest-html

pytest.main(['--html=output.html'])  ---用的不多

多的是allure平台

10、安装allure

搜索allure-pytest,仅生成数据

1、 pip install allure-pytest

2、下载服务: allure-commandline https://github.com/allure-framework/allure

3、安装平台的服务 下载后解压,复制bin路径, 配置环境变量 bin目录的路径放在path下面,记得重启电脑

生成测试报告:使⽤ pytest.main(['--alluredir=report'])  report是目录

终端执行命令,  allure serve report   # report是目录

 

posted @ 2022-03-27 22:23  依羽杉  阅读(55)  评论(0编辑  收藏  举报