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是目录

 

相关文章

目录1、前言2、mark的使用(一)注册自定义标记(二)在测试...
用例执行状态用例执行完成后,每条用例都有自己的状态,常见...
什么是conftest.py可以理解成一个专门存放fixture的配置文件...
前言pytest默认执行用例是根据项目下的文件名称按ascii码去收...
前言:什么是元数据?元数据是关于数据的描述,存储着关于数...