美文网首页
接口自动化

接口自动化

作者: LP_ProgramLife | 来源:发表于2018-03-16 14:53 被阅读24次

import time,os

import sys

import unittest

from HTMLTestRunnerimport HTMLTestRunner

sys.path.append("./Interface")

#指定当前文件夹下的Interface目录

test_dir ="./interface"

#匹配开头为test的py文件

file =unittest.defaultTestLoader.discover(test_dir,pattern="*_test.py")

if __name__ =="__main__":

# 取当前时间

    now = time.strftime("%Y-%m-%d %H-%M-%S",time.localtime(time.time()))

# 获取当前运行的.py文件所在的绝对路径

    public_path = os.path.dirname(os.path.abspath(sys.argv[0]))

#保存的报告路径和名称

    filename = public_path +"\\Report\\" + now +"report.html"

    fp =open(filename,"wb")

runner = HTMLTestRunner(stream=fp,

title="接口自动化报告",

description="详细描述如下:"

    )

#执行测试套件

    runner.run(file)

fp.close()

相关文章

网友评论

      本文标题:接口自动化

      本文链接:https://www.haomeiwen.com/subject/fzzlqftx.html