Commit 3cdc4811 by jiaqiying

根据传入的产品名来运行对应产品的测试用例

parent 13cae9ed
......@@ -3,7 +3,7 @@
import json
import logging
import requests
from config import BaseConfig
from config import BaseConfig, BMCConfig
def request_main(url, headers, method, data):
......@@ -28,4 +28,11 @@ def request_main(url, headers, method, data):
if res != None:
return res.json()
return res
\ No newline at end of file
return res
def get_case_dir(product_name):
test_case_dir = BaseConfig.default_test_case_dir
if product_name == BMCConfig.name:
test_case_dir = BMCConfig.test_case_dir
return test_case_dir
\ No newline at end of file
......@@ -5,12 +5,15 @@ class BaseConfig():
# 请求头
headers = {'Content-Type': 'application/json; charset=utf-8'}
# 当前运行的产品名
current_product = ""
current_product = "bmc"
default_test_case_dir = "test_case/bmc/"
class BMCConfig(BaseConfig):
"""斑马信用app的配置类"""
pass
# 测试用例目录
name = "bmc"
test_case_dir = "test_case/bmc/"
class DingTalk(BaseConfig):
......
#coding:utf-8
import os
import pytest
import argparse
from config import BaseConfig
from common.tools import get_case_dir
def get_parser():
parser = argparse.ArgumentParser(description="Demo of argparse")
parser.add_argument('--product', type=str, default=BaseConfig.current_product)
return parser
if __name__ == "__main__":
parser = get_parser()
args = get_parser()
# 获取要执行的产品的用例目录
test_case_dir = get_case_dir(args.product)
#删除之前报告
for one in os.listdir('../report/tmp'):
if 'json' in one:
os.remove(f'../report/tmp/{one}')
# 生成报告数据
pytest.main([ '-s', '--alluredir', '../report/tmp'])
pytest.main(['-v', '-s', test_case_dir, '--alluredir', '../report/tmp'])
# 打开报告
os.system('allure serve ../report/tmp')
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment