1 Star 0 Fork 0

William/MyTestFrame3

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
runUnitTest.py 1.77 KB
一键复制 编辑 原始数据 按行查看 历史
Will 提交于 2019-08-28 22:34 +08:00 . 更新单元测试运行
# -*- coding: UTF-8 -*-
import unittest,sys
from BeautifulReport import BeautifulReport as bf
from utest import datadriven
from common import config
from common.mysql import Mysql
from common import logger
# 运行的相对路径
path = '.'
# 用例路径
casepath = ''
resultpath = ''
if __name__ == '__main__':
# unittest.main()
# suite = unittest.TestSuite()
# suite.addTests(unittest.defaultTestLoader.loadTestsFromTestCase(testWeb))
# suite = unittest.defaultTestLoader.discover(".", pattern="baidu.py", top_level_dir=None)
# # 生成执行用例的对象
# runner = bf(suite)
# runner.report(filename='./test.html', description='这个描述参数是必填的')
try:
casepath = sys.argv[1]
except:
casepath = ''
# 为空,则使用默认的
if casepath == '':
casepath = path + '/lib/SOAP.xls'
resultpath = path + '/lib/结果-SOAP.xls'
else:
# 如果是绝对路径,就使用绝对路径
if casepath.find(':') >= 0:
# 获取用例文件名
resultpath = path + '/lib/结果-' + casepath[casepath.rfind('\\') + 1:]
else:
logger.error('非法用例路径')
config.get_config(path + '/lib/conf.properties')
# logger.info(config.config)
mysql = Mysql()
mysql.init_mysql(path + '/lib/userinfo.sql')
datadriven.getparams(casepath,resultpath)
# print(datadriven.alllist)
# unittest.main()
# suite = unittest.TestSuite()
# suite.addTests(unittest.defaultTestLoader.loadTestsFromTestCase(baidu))
suite = unittest.defaultTestLoader.discover("./utest/", pattern="WebTest.py", top_level_dir=None)
# 生成执行用例的对象
runner = bf(suite)
runner.report(filename='./test.html', description=datadriven.title)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/willtesting/MyTestFrame3.git
git@gitee.com:willtesting/MyTestFrame3.git
willtesting
MyTestFrame3
MyTestFrame3
master

搜索帮助