当前位置: 首页 > article >正文

04、pytest运行多个测试用例

官方用例

目录结构

course_04
|
|----subdir
|		|
|		|----sample03_test.py
|		|
|		|----test_sample04.py
|
|----sample02_test.py
|
|----test_sample01.py
# content of test_sample01.py

def test_simple01():
    print("test simple01")
    assert 0
# content of test_sample02_test.py

def test_simple02():
    print("test simple02")
    assert 0
# content of sample03_test.py

def test_simple03():
    print("test simple03")
    assert 0
# content of test_sample04.py

def test_simple04():
    print("test simple04")
    assert 0

在这里插入图片描述

场景应用

​ pytest将运行当前目录及其子目录中所有形式为test_*.py或*_test.py的文件。更一般地说,它遵循标准的测试发现规则。

其它想法

​ 项目测试中,一个项目编写一个测试目录,每个大模块编写一个test_<模块名>.py文件,每个模块中每条测试用例编写一个test_<用例名>函数,每次回归时,在测试目录下执行pytest,并查看运行效果。


http://www.kler.cn/a/157712.html

相关文章:

  • 配置Docker OpenWrt与宿主机网络互通且作为宿主机网关
  • CSS实现一些小功能
  • Vue3使用vue-baidu-map-3x百度地图
  • 使用axios下载后端接口返回的文件流格式文件
  • C++ ini配置文件的简单读取使用
  • 【腾讯云云上实验室】个人对腾讯云向量数据库的体验心得
  • 第一节JavaScript 简介与使用
  • springboot-技术栈汇总
  • 3.5毫米音频连接器接线方式
  • Linux scatterlist 详解
  • 【Filament】Filament环境搭建
  • @Scheduled,Quartz,XXL-JOB三种定时任务总结
  • java使用xstream框架生成xml文件
  • MySQL导出ER图为图片或PDF
  • uniapp 云打包 生成安卓证书文件
  • 【Redis实现全局唯一ID】
  • Linux lshw命令(lshw指令)(List Hardware,获取底层硬件信息)(查询硬件信息)
  • python中字符串的常用方法
  • PostgreSQL 连接更新操作
  • 京东数据分析(京东数据运营):2023年10月咖啡市场销售数据分析(商家销量销额店铺数据)