HTML测试报告:
1、下载HTMLTestRunner:http://tungwaiyip.info/software/HTMLTestRunner.html
2、将HTMLTestRunner加入到你测试项目中
3、添加使用方法:
def run_suite_output_html_report(suite, **args):
'''
:param suite: 已组装好的测试套
:param args: 可设置的参数及说明如下:
TEST_OUTPUT_DIR:测试报告输出路径,默认为根目录
TEST_OUTPUT_FILE_NAME:测试报告输入文件名,默认为index.html
:return:
'''
output_dir = args.get('TEST_OUTPUT_DESCRIPTIONS', load_lib_path.UI_TEST_REPORT_DIR)
single_file = args.get('TEST_OUTPUT_FILE_NAME', 'index.html')
file_path = os.path.join(output_dir, single_file)
fp = file(file_path, 'wb')
htmlrunner = HTMLTestRunner.HTMLTestRunner(stream=fp, title=u'uiautotestreport', description=u'ui autotest on chrome')
htmlrunner.run(suite)
XML测试报告:
1、下载如下附件
unittest_xml_reporting-2.1.0-py2.py3-none-any.whl
2、通过PIP进行安装: pip install unittest_xml_reporting-2.1.0-py2.py3-none-any.whl
3、添加使用方法:
def run_suite_output_xml_report(suite, **args):
'''
:param suite: 已组装好的测试套
:param args: 可设置的参数及说明如下:
TEST_OUTPUT_DESCRIPTIONS: 输出描述
TEST_OUTPUT_DIR:测试报告输出路径,默认为根目录
TEST_OUTPUT_FILE_NAME:测试报告输入文件名,默认为hsplatform_ut_testreport.xml
:return:
'''
descriptions = args.get('TEST_OUTPUT_DESCRIPTIONS', True)
output_dir = args.get('TEST_OUTPUT_DESCRIPTIONS', load_lib_path.UI_TEST_REPORT_DIR)
single_file = args.get('TEST_OUTPUT_FILE_NAME', 'hsplatform_ut_testreport.xml')
kwargs = dict(verbosity=1, descriptions=descriptions, failfast=False)
if single_file is not None:
file_path = os.path.join(output_dir, single_file)
with open(file_path, 'wb') as xml:
return xmlrunner.XMLTestRunner(output=xml, **kwargs).run(suite)
else :
return xmlrunner.XMLTestRunner(output=output_dir, **kwargs).run(suite)