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


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

    1. import pytest
    2. class Test_Smoke:
    3. def test_01(self):
    4. assert 1+1==2
    5. @pytest.mark.smoke
    6. def test_02(self):
    7. assert 1+2==1
    8. @pytest.mark.smoke
    9. def test_03(self):
    10. assert 1 + 2 == 3

    2.配置文件pytest.ini

    1. [pytest]
    2. markers =
    3. smoke

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

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

    4. 运行结果

    1. ============================= test session starts =============================
    2. platform win32 -- Python 3.10.9, pytest-7.1.2, pluggy-1.0.0 -- D:\software\python3\anconda3\python.exe
    3. cachedir: .pytest_cache
    4. 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'}
    5. rootdir: E:\data\web测试\Selenium3自动化测试实战——基于Python语言\mycode\pytest_example, configfile: pytest.ini
    6. plugins: anyio-3.5.0, base-url-2.0.0, html-4.0.2, metadata-3.0.0, rerunfailures-12.0
    7. collecting ... collected 3 items / 1 deselected / 2 selected
    8. somke_test/test_smoke.py::Test_Smoke::test_02 FAILED
    9. somke_test/test_smoke.py::Test_Smoke::test_03 PASSED
    10. ================================== FAILURES ===================================
    11. _____________________________ Test_Smoke.test_02 ______________________________
    12. self = <test_smoke.Test_Smoke object at 0x0000014593190F10>
    13. @pytest.mark.smoke
    14. def test_02(self):
    15. > assert 1+2==1
    16. E assert (1 + 2) == 1
    17. somke_test\test_smoke.py:8: AssertionError
    18. - 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 -
    19. =========================== short test summary info ===========================
    20. FAILED somke_test/test_smoke.py::Test_Smoke::test_02 - assert (1 + 2) == 1
    21. ================== 1 failed, 1 passed, 1 deselected in 0.34s ==================
    22. Process finished with exit code 0

  • 相关阅读:
    Jupyter使用技巧
    Java常用17个工具类方法,提升开发效率的“轮子”,避免重复造轮子
    常见的配置文件格式:yaml,json,xml,ini,csv等
    短视频源码php
    【SQL注入点】注入点出现位置、判断
    JAVA毕业设计科技项目在线评审系统计算机源码+lw文档+系统+调试部署+数据库
    【计算机网络】HTTPS协议的加密流程
    【动态规划】1143. 最长公共子序列
    Centos7 Shell编程之函数、消息的发送与接收
    UE4 距离场
  • 原文地址:https://blog.csdn.net/oDianZi1234567/article/details/133062748