mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-12 02:21:29 +08:00
feat: add gen_html_report method for HttpRunner class
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user