pytest--用例標簽


用例標簽:

 執行測試用例:pytest 測試套件名 -m 標簽名 

import pytest
'''
用例標簽:
  @pytest.mark.標簽名  
  執行測試:pytest 測試套件名 -m 標簽名
  這樣執行會有警告,提示標簽未注冊
注冊標簽:
方式一:
  創建配置文件pytest.ini 
  [pytest]
  markers =
    tag1:tag description  # 標簽描述,可以不寫
    tag2:
方式二:
    創建conftest.py文件,存放在命令行當前目錄
    def pytest_configure(config):
        config.addinivalue_line('markers','回歸測試')
        config.addinivalue_line('markers','標簽名')
    
'''
@pytest.mark.smoketest
def test_01():
    print('開始執行測試用例1')

@pytest.mark.冒煙
def test_02():
    print('開始執行測試用例2')
@pytest.mark.回歸測試
def test_03():
    print('開始執行測試用例3')

標簽注冊文件:

  pytest.ini

  

[pytest]
markers =
    tag1:tag description  # 標簽描述,可以不寫
    tag2:tag2
    smoketest:
    冒煙:

  configtest.py

  

def pytest_configure(config):
    config.addinivalue_line('markers','回歸測試')
    config.addinivalue_line('markers','標簽名')

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM