标签:stc desc title port tca sts script for 等等
说明:待执行测试用例放到"d:\\Python37\\testcase",文件命名格式可改成test1.py,test2.py等等,文件名不要有空格,否则识别不了。
#coding:utf-8
import unittest
import HTMLTestRunner
def all_case():
#待执行用例的目录
case_dir="d:\\Python37\\testcase"
testcase = unittest.TestSuite()
#pattern是测试用例的名称样式
discover=unittest.defaultTestLoader.discover(case_dir,pattern="test*.py",top_level_dir=None)
for test_suite in discover:
for test_case in test_suite:
testcase.addTests(test_case)
return testcase
if __name__=="__main__":
#输出报告地址,目录需提前手动创建
report_path="d:\\Python37\\testcase\\report\\result.html"
fp = open(report_path,"wb")
runner = HTMLTestRunner.HTMLTestRunner(stream=fp,
title="这是我的自动化测试报告",
description="用例执行情况:")
runner.run(all_case())
fp.close()
标签:stc desc title port tca sts script for 等等
原文地址:https://www.cnblogs.com/xiaohuhu/p/9384587.html