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,并查看运行效果。

相关推荐

  1. pytest+allure批量执行测试

    2023-12-08 20:04:02       54 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2023-12-08 20:04:02       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2023-12-08 20:04:02       106 阅读
  3. 在Django里面运行非项目文件

    2023-12-08 20:04:02       87 阅读
  4. Python语言-面向对象

    2023-12-08 20:04:02       96 阅读

热门阅读

  1. LeetCode //C - 188. Best Time to Buy and Sell Stock IV

    2023-12-08 20:04:02       58 阅读
  2. 初识 OpenCV

    2023-12-08 20:04:02       64 阅读
  3. Leetcode 344. Reverse String

    2023-12-08 20:04:02       57 阅读
  4. rabbitmq的路由策略

    2023-12-08 20:04:02       59 阅读
  5. tomcat 如何优化?

    2023-12-08 20:04:02       55 阅读
  6. 数据库函数大全(更新中)

    2023-12-08 20:04:02       54 阅读
  7. 解决Qt发送信号指定重载

    2023-12-08 20:04:02       58 阅读
  8. Glide系列-生命周期的监听

    2023-12-08 20:04:02       52 阅读
  9. macOS sandbox 获取用户路径文件夹

    2023-12-08 20:04:02       49 阅读
  10. final, finally, finalize的区别

    2023-12-08 20:04:02       49 阅读
  11. 算法训练营Day9(字符串,以后补KMP)

    2023-12-08 20:04:02       60 阅读