需求:项目测试环境太多了,各种测试环境升级到最新版本前需要准备测试数据,每次都是手动准备,耗时费劲,
解决办法:运行httprunner接口测试框架里面的准备测试数据的用例,这里是进行指定用例的思路。
方法一:标记httpruner的用例,使用@pytest.mark.data(),运行标记用例即可。
[pytest]
addopts = -vs --html D:/se_frame/Reports/report.html -n=2 --reruns=2
testpaths = D:/se_frame/TestCases
python_files = test*
python_classes = Test*
python_functions = test*
markers =
smoke
data
# coding=utf-8
import os, allure, pytest, logging.config
@allure.feature("模块名XXX")
class Test_layerlevel_management:
@pytest.mark.smoke()
@allure.title("展开和关闭图层")
@pytest.mark.run(order=1)
def test_xxx1(self, po_layer):
po_layer.layer_hide()
@pytest.mark.smoke()
@allure.title("最小级别全部加1")
@pytest.mark.run(order=1)
def test_xxx2(self, po_layer):
po_layer.layer_edit_min()
if __name__ == '__main__':
# 执行某一类data用例,这个主要是为了准备升级前的测试数据。
pytest.main(["-s", "test_webtest.py", "-m=data"])
实现方式2:新建data_suit.py文件,里面的py文件用逗号隔开即可。
import pytest
if __name__ == "__main__":
pytest.main(["-v", "test_001.py", "test_002.py"])