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

【pytest】 标记冒烟用例 @pytest.mark.smoke

1. 使用 @pytest.mark.smoke 标记用例


import pytest
class Test_Smoke:def test_01(self):assert 1+1==2@pytest.mark.smokedef test_02(self):assert 1+2==1@pytest.mark.smokedef test_03(self):assert 1 + 2 == 3

2.配置文件pytest.ini

[pytest]
markers =smoke

3.  运行指定标签  运行指定标签 pytest -m "标记名"

#----------------------------冒烟用例标记--------------------------------------pytest.main(['-s', '-v','-m smoke','./somke_test', '--html=./report/result.html'])

4. 运行结果

============================= test session starts =============================
platform win32 -- Python 3.10.9, pytest-7.1.2, pluggy-1.0.0 -- D:\software\python3\anconda3\python.exe
cachedir: .pytest_cache
metadata: {'Python': '3.10.9', 'Platform': 'Windows-10-10.0.19045-SP0', 'Packages': {'pytest': '7.1.2', 'pluggy': '1.0.0'}, 'Plugins': {'anyio': '3.5.0', 'base-url': '2.0.0', 'html': '4.0.2', 'metadata': '3.0.0', 'rerunfailures': '12.0'}, 'JAVA_HOME': 'D:\\software\\Java\\jdk1.8.0_151'}
rootdir: E:\data\web测试\Selenium3自动化测试实战——基于Python语言\mycode\pytest_example, configfile: pytest.ini
plugins: anyio-3.5.0, base-url-2.0.0, html-4.0.2, metadata-3.0.0, rerunfailures-12.0
collecting ... collected 3 items / 1 deselected / 2 selectedsomke_test/test_smoke.py::Test_Smoke::test_02 FAILED
somke_test/test_smoke.py::Test_Smoke::test_03 PASSED================================== FAILURES ===================================
_____________________________ Test_Smoke.test_02 ______________________________self = <test_smoke.Test_Smoke object at 0x0000014593190F10>@pytest.mark.smokedef test_02(self):
>       assert 1+2==1
E       assert (1 + 2) == 1somke_test\test_smoke.py:8: AssertionError
- Generated html report: file:///E:/data/web%E6%B5%8B%E8%AF%95/Selenium3%E8%87%AA%E5%8A%A8%E5%8C%96%E6%B5%8B%E8%AF%95%E5%AE%9E%E6%88%98%E2%80%94%E2%80%94%E5%9F%BA%E4%BA%8EPython%E8%AF%AD%E8%A8%80/mycode/pytest_example/report/result.html -
=========================== short test summary info ===========================
FAILED somke_test/test_smoke.py::Test_Smoke::test_02 - assert (1 + 2) == 1
================== 1 failed, 1 passed, 1 deselected in 0.34s ==================Process finished with exit code 0

http://www.lryc.cn/news/173295.html

相关文章:

  • 数据结构入门-14-排序
  • Gin学习记录4——Controller和中间件
  • FL Studio21.2中文版数字音乐制作软件
  • ELK 企业级日志分析系统 ELFK
  • IDEA中创建Java Web项目方法1
  • 源码:TMS FlexCel Studio for .NET 7.19
  • 多输入多输出 | MATLAB实现PSO-BP粒子群优化BP神经网络多输入多输出
  • 操作系统:系统引导以及虚拟机
  • AIGC绘本——海马搬家来喽
  • strtok()函数的使用方法
  • Matlab中的handle 类
  • C#,数值计算——Multinormaldev的计算方法与源程序
  • 软件项目测试用例评审
  • 图像处理与计算机视觉--第二章-成像与图像表示-8问
  • python中使用多线程批量导入包
  • 齿轮减速机设备类网站pbootcms模板(PC端+手机端自适应)
  • MySQL报错:this is incompatible with sql_mode=only_full_group_by 解决方法
  • impala常用时间函数,date->string->timestamp互转
  • 无源供电无线测温系统的应用意义
  • 使用 PyTorch 的计算机视觉简介 (1/6)
  • 用PHP实现极验验证功能
  • 【数据结构初阶】三、 线性表里的链表(无头+单向+非循环链表)
  • Mybatis 映射器与XML配置职责分离
  • 微服务引擎
  • 前端JavaScript入门到精通,javascript核心进阶ES6语法、API、js高级等基础知识和实战 —— JS基础(三)
  • 搭建部署属于自己的基于gpt3.5的大语言模型(基于flask+html+css+js+mysql实现)
  • AI创作专家,免费的AI创作专家工具
  • Nginx之gzip模块解读
  • 微软在Windows 11推出Copilot,将DALL-E 3集成在Bing!
  • SLAM从入门到精通(消息传递)