脚本树如下:

test1文件下test_01.py存放test1和test2用例

test1文件下test_02.py存放test1和test2用例

test2文件下test_03.py存放test1和test2用例

test2文件下test_04.py存放test1和test2用例

1、运行所有用例
import pytest
if __name__ == "__main__":pytest.main(['-s',''])"C:\Program Files\Python35\python.exe" C:/Users/wangli/PycharmProjects/PytestAutomation/testcase/run_all_test.py
============================= test session starts =============================
platform win32 -- Python 3.5.2, pytest-5.1.2, py-1.8.0, pluggy-0.12.0
rootdir: C:\Users\wangli\PycharmProjects\PytestAutomation\testcase
plugins: allure-pytest-2.8.5, html-1.22.0, metadata-1.8.0
collected 8 itemstest1\test_01.py 调用了获取token
test_01-test1:5
.test_01-test2:5
.
test1\test_02.py test_02-test1:5
.test_02-test2:5
.
test2\test_03.py test_03-test1:5
.test_04-test2:5
.
test2\test_04.py test04-test1:5
.test04-test2:5
.============================== 8 passed in 0.25s ==============================Process finished with exit code 0
--------------------------------------------------------------------------------------2、运行指定文件夹下用例
import pytest
if __name__ == "__main__":pytest.main(['-s','test1'])"C:\Program Files\Python35\python.exe" C:/Users/wangli/PycharmProjects/PytestAutomation/testcase/run_all_test.py
============================= test session starts =============================
platform win32 -- Python 3.5.2, pytest-5.1.2, py-1.8.0, pluggy-0.12.0
rootdir: C:\Users\wangli\PycharmProjects\PytestAutomation\testcase
plugins: allure-pytest-2.8.5, html-1.22.0, metadata-1.8.0
collected 4 itemstest1\test_01.py 调用了获取token
test_01-test1:5
.test_01-test2:5
.
test1\test_02.py test_02-test1:5
.test_02-test2:5
.============================== 4 passed in 0.12s ==============================Process finished with exit code 0-----------------------------------------------------------------------------------3、运行指定py文件下用例
import pytest
if __name__ == "__main__":pytest.main(['-s','test1/test_01.py'])"C:\Program Files\Python35\python.exe" C:/Users/wangli/PycharmProjects/PytestAutomation/testcase/run_all_test.py
============================= test session starts =============================
platform win32 -- Python 3.5.2, pytest-5.1.2, py-1.8.0, pluggy-0.12.0
rootdir: C:\Users\wangli\PycharmProjects\PytestAutomation\testcase
plugins: allure-pytest-2.8.5, html-1.22.0, metadata-1.8.0
collected 2 itemstest1\test_01.py 调用了获取token
test_01-test1:5
.test_01-test2:5
.============================== 2 passed in 0.04s ==============================Process finished with exit code 04、运行指定类下的用例
import pytest
if __name__ == "__main__":pytest.main(['-s','test1/test_01.py::Test'])"C:\Program Files\Python35\python.exe" C:/Users/wangli/PycharmProjects/PytestAutomation/testcase/run_all_test.py
============================= test session starts =============================
platform win32 -- Python 3.5.2, pytest-5.1.2, py-1.8.0, pluggy-0.12.0
rootdir: C:\Users\wangli\PycharmProjects\PytestAutomation\testcase
plugins: allure-pytest-2.8.5, html-1.22.0, metadata-1.8.0
collected 2 itemstest1\test_01.py 调用了获取token
test_01-test1:5
.test_01-test2:5
.============================== 2 passed in 0.04s ==============================Process finished with exit code 0-------------------------------------------------------------------------------------5、运行执行方法下的用例
import pytest
if __name__ == "__main__":pytest.main(['-s','test1/test_01.py::Test::test1'])"C:\Program Files\Python35\python.exe" C:/Users/wangli/PycharmProjects/PytestAutomation/testcase/run_all_test.py
============================= test session starts =============================
platform win32 -- Python 3.5.2, pytest-5.1.2, py-1.8.0, pluggy-0.12.0
rootdir: C:\Users\wangli\PycharmProjects\PytestAutomation\testcase
plugins: allure-pytest-2.8.5, html-1.22.0, metadata-1.8.0
collected 1 itemtest1\test_01.py 调用了获取token
test_01-test1:5
.============================== 1 passed in 0.04s ==============================Process finished with exit code 0

Pytest脚本中运行用例方式相关推荐

  1. Octave matlab中运行.m文件方式对比

    Octave用起来和Matlab相比感觉还是有些不太方便,比如在Matlab中运行一个test.m文件,可以在matlab的命令行上: 1.直接输入该文件名字回车,比如>>test,回车 ...

  2. LoadRunner12_脚本中运行JavaScrip

    版权声明:本文为博主原创文章,未经博主允许不得转载. [系统及软件配置] LR版本:12.53 JDK版本:1.8 函数:web_js_run,该函数仅在LR12版本提供支持,LR11不支持JavaS ...

  3. linux shell脚本 wget,bash – 在shell脚本中运行wget和其他命令

    以下是编写shell脚本时要使用的一些准则. >使用它们时始终引用变量.这有助于避免误解的可能性. (如果文件名包含空格怎么办?) >不要相信像rm这样的命令上的文件加载.请改用循环. ( ...

  4. python代码直接关机_关机信号在python脚本中运行代码

    shutdown发送SIGTERM信号,atexit无法处理.背景管理者也不会,最后是块等. import signal signal.getsignal(signal.SIGTERM) Out[64 ...

  5. Shell脚本中获取命令运行结果、特殊变量使用、条件判断等常用操作

    文章目录 前言 获取命令执行结果 使用反引号 `` ` ``command `` ` ``来执行命令 使用括号组合 $(command) 来执行命令 两种方式的区别 特殊变量使用 $0 $1 $2 . ...

  6. 为什么“ cd”在shell脚本中不起作用?

    我正在尝试编写一个小脚本以将当前目录更改为我的项目目录: #!/bin/bash cd /home/tree/projects/java 我将此文件另存为proj,并使用chmod添加了执行权限,然后 ...

  7. 【Pytest篇】pytest生成报告的几种方式

    使用Pytest生成测试报告的几种方式 1.生成Junitxml文件,可供后续jenkins持续集成使用 在cmd 命令行中执行如下命令 pytest test_login_dlz.py --juni ...

  8. Python + Pytest 自动化框架的用例依赖实操

    今日分享主题:Python + Pytest 自动化框架中测试用例依赖的探索与实践,今天分享的内容以"依赖别名+scope='package'"进行演示. 1.安装 pytest- ...

  9. shell脚本for循环_了解Shell脚本中的for循环

    shell脚本for循环 Continuing on from our previous tutorials, let's understand the for loop in shell scrip ...

最新文章

  1. 详解log4j2(上) - 从基础到实战
  2. 特征选择常用算法综述
  3. 通俗易懂解释知识图谱
  4. 武汉国家光电实验室计算机考研,2018年华中科技大学武汉国家光电实验室408计算机学科专业基础综合之计算机操作系统考研基础五套测试题...
  5. 2017.9.22 middle 失败总结
  6. Python数据结构之字节,字节数组
  7. pycharm添加python注释头_pycharm使用教程——py文件自动添加文件头注释
  8. python手册中文版pdf-python中文官方文档 PDF 下载
  9. 厦门市建筑物矢量数据(Shp格式+带高度)
  10. java 球弹跳的高度_关于皮球弹跳高度的几个问题
  11. 网站被黑跳转到其他网站的解决办法
  12. 电脑重装系统,如何下载正版win10的iso
  13. U盘偷资料神器,我都不太敢分享了。
  14. java计算机毕业设计科院垃圾分类系统源码+数据库+系统+lw文档+mybatis+运行部署
  15. 电话机器人效果怎么样,电话机器人代理
  16. 世界杯电视直播表(及时更新)
  17. matlab求传递函数在某个频率点的增益_EQ均衡器频率特性的原理——Q值与带宽、滤波器...
  18. Shell之function函数的定义及调用
  19. shell 编程的老臣 - sed
  20. 爬取大众点评数据的血泪史

热门文章

  1. db2 最大分区数_db2 查询表分区数据库
  2. pythonmulti函数_python – 用于使用MultiIndex创建pandas系列的语法糖
  3. python函数内的作用域包括什么_python菜鸟求问关于嵌套函数中作用域范围应该怎么理解?...
  4. 多层html怎么找到密码输入框,Vant PasswordInput 密码输入框
  5. python绘制饼图程序_python使用Matplotlib绘制饼图
  6. MySQL日期类型的处理总结
  7. 数据列表的分页实现————分页敏捷开发
  8. 以下表示中 不能用作c语言常量的是0UL,C语言笔试卷.doc
  9. 2021曲靖高考成绩查询时间,2021年曲靖高考成绩排名及成绩公布时间什么时候出来...
  10. linux重启was控制台报错,IHS启动时报错,从was控制台传播插件失败