feat: add gen_html_report method for HttpRunner class

This commit is contained in:
debugtalk
2020-04-23 16:48:43 +08:00
parent 6dda579be8
commit 1fb20e948f
2 changed files with 8 additions and 3 deletions

View File

@@ -24,7 +24,6 @@ from httprunner.v3.api import HttpRunner
from httprunner.ext.har2case import init_har2case_parser, main_har2case
from httprunner.ext.scaffold import init_parser_scaffold, main_scaffold
from httprunner.ext.locusts import init_parser_locusts, main_locusts
from httprunner.report import gen_html_report
def init_parser_run(subparsers):
@@ -75,8 +74,7 @@ def main_run(args):
for path in args.testfile_paths:
testsuite_summary = runner.run_path(path, dot_env_path=args.dot_env_path)
report_dir = args.report_dir or os.path.join(os.getcwd(), "reports")
gen_html_report(
testsuite_summary,
runner.gen_html_report(
report_template=args.report_template,
report_dir=report_dir,
report_file=args.report_file

View File

@@ -6,6 +6,7 @@ from typing import List, Dict
from loguru import logger
from httprunner import report, loader, utils, exceptions, __version__
from httprunner.report import gen_html_report
from httprunner.v3.runner import TestCaseRunner
from httprunner.v3.schema import TestsMapping, TestCaseSummary, TestSuiteSummary
@@ -279,3 +280,9 @@ class HttpRunner(object):
return self.run_tests(path_or_tests)
else:
raise exceptions.ParamsError(f"Invalid testcase path or testcases: {path_or_tests}")
def gen_html_report(self, report_template=None, report_dir=None, report_file=None):
if not self._summary:
return None
return gen_html_report(self._summary, report_template, report_dir, report_file)