mirror of
https://github.com/httprunner/httprunner.git
synced 2026-07-06 06:51:23 +08:00
change: rename render_html_report to gen_html_report
This commit is contained in:
@@ -2,9 +2,15 @@
|
|||||||
|
|
||||||
## 2.3.2 (2019-11-01)
|
## 2.3.2 (2019-11-01)
|
||||||
|
|
||||||
|
**Added**
|
||||||
|
|
||||||
|
- docs: add docs content to repo, visit at `https://docs.httprunner.org`
|
||||||
|
- docs: update developer interface docs
|
||||||
|
|
||||||
**Changed**
|
**Changed**
|
||||||
|
|
||||||
- make render_html_report separate with HttpRunner().run_tests()
|
- rename `render_html_report` to `gen_html_report`
|
||||||
|
- make gen_html_report separate with HttpRunner().run_tests()
|
||||||
- `--report-file`: specify report file path, this has higher priority than specifying report dir.
|
- `--report-file`: specify report file path, this has higher priority than specifying report dir.
|
||||||
- remove `summary` property from HttpRunner
|
- remove `summary` property from HttpRunner
|
||||||
|
|
||||||
|
|||||||
@@ -314,12 +314,12 @@ summary = runner.run(path_or_tests)
|
|||||||
|
|
||||||
## 生成 HTML 测试报告
|
## 生成 HTML 测试报告
|
||||||
|
|
||||||
如需生成 HTML 测试报告,可调用 `report.render_html_report` 方法。
|
如需生成 HTML 测试报告,可调用 `report.gen_html_report` 方法。
|
||||||
|
|
||||||
```python
|
```python
|
||||||
from httprunner import report
|
from httprunner import report
|
||||||
|
|
||||||
report_path = report.render_html_report(
|
report_path = report.gen_html_report(
|
||||||
summary,
|
summary,
|
||||||
report_template="/path/to/custom_report_template",
|
report_template="/path/to/custom_report_template",
|
||||||
report_dir="/path/to/reports_dir",
|
report_dir="/path/to/reports_dir",
|
||||||
@@ -327,7 +327,7 @@ report_path = report.render_html_report(
|
|||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
`render_html_report()` 的参数有四个:
|
`gen_html_report()` 的参数有四个:
|
||||||
|
|
||||||
- summary(必传): 测试运行结果汇总数据
|
- summary(必传): 测试运行结果汇总数据
|
||||||
- report_template(可选): 指定自定义的 HTML 报告模板,模板必须采用 Jinja2 的格式
|
- report_template(可选): 指定自定义的 HTML 报告模板,模板必须采用 Jinja2 的格式
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ from httprunner import __description__, __version__
|
|||||||
from httprunner.api import HttpRunner
|
from httprunner.api import HttpRunner
|
||||||
from httprunner.compat import is_py2
|
from httprunner.compat import is_py2
|
||||||
from httprunner.logger import color_print
|
from httprunner.logger import color_print
|
||||||
from httprunner.report import render_html_report
|
from httprunner.report import gen_html_report
|
||||||
from httprunner.utils import (create_scaffold, get_python2_retire_msg,
|
from httprunner.utils import (create_scaffold, get_python2_retire_msg,
|
||||||
prettify_json_file)
|
prettify_json_file)
|
||||||
from httprunner.validator import validate_json_file
|
from httprunner.validator import validate_json_file
|
||||||
@@ -94,7 +94,7 @@ def main():
|
|||||||
for path in args.testcase_paths:
|
for path in args.testcase_paths:
|
||||||
summary = runner.run(path, dot_env_path=args.dot_env_path)
|
summary = runner.run(path, dot_env_path=args.dot_env_path)
|
||||||
report_dir = args.report_dir or os.path.join(runner.project_working_directory, "reports")
|
report_dir = args.report_dir or os.path.join(runner.project_working_directory, "reports")
|
||||||
render_html_report(
|
gen_html_report(
|
||||||
summary,
|
summary,
|
||||||
args.report_template,
|
args.report_template,
|
||||||
report_dir,
|
report_dir,
|
||||||
|
|||||||
@@ -276,7 +276,7 @@ def __stringify_meta_datas(meta_datas):
|
|||||||
__stringify_response(data["response"])
|
__stringify_response(data["response"])
|
||||||
|
|
||||||
|
|
||||||
def render_html_report(summary, report_template=None, report_dir=None, report_file=None):
|
def gen_html_report(summary, report_template=None, report_dir=None, report_file=None):
|
||||||
""" render html report with specified report name and template
|
""" render html report with specified report name and template
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
|||||||
@@ -188,7 +188,7 @@ class TestHttpRunner(ApiServerUnittest):
|
|||||||
self.assertEqual(summary["stat"]["teststeps"]["skipped"], 4)
|
self.assertEqual(summary["stat"]["teststeps"]["skipped"], 4)
|
||||||
|
|
||||||
report_save_dir = os.path.join(os.getcwd(), 'reports', "demo")
|
report_save_dir = os.path.join(os.getcwd(), 'reports', "demo")
|
||||||
report.render_html_report(summary, report_dir=report_save_dir)
|
report.gen_html_report(summary, report_dir=report_save_dir)
|
||||||
self.assertGreater(len(os.listdir(report_save_dir)), 0)
|
self.assertGreater(len(os.listdir(report_save_dir)), 0)
|
||||||
shutil.rmtree(report_save_dir)
|
shutil.rmtree(report_save_dir)
|
||||||
|
|
||||||
@@ -200,7 +200,7 @@ class TestHttpRunner(ApiServerUnittest):
|
|||||||
self.assertEqual(summary["stat"]["teststeps"]["skipped"], 4)
|
self.assertEqual(summary["stat"]["teststeps"]["skipped"], 4)
|
||||||
|
|
||||||
report_file = os.path.join(os.getcwd(), 'reports', "demo", "test.html")
|
report_file = os.path.join(os.getcwd(), 'reports', "demo", "test.html")
|
||||||
report.render_html_report(summary, report_file=report_file)
|
report.gen_html_report(summary, report_file=report_file)
|
||||||
report_save_dir = os.path.dirname(report_file)
|
report_save_dir = os.path.dirname(report_file)
|
||||||
self.assertEqual(len(os.listdir(report_save_dir)), 1)
|
self.assertEqual(len(os.listdir(report_save_dir)), 1)
|
||||||
self.assertTrue(os.path.isfile(report_file))
|
self.assertTrue(os.path.isfile(report_file))
|
||||||
@@ -272,7 +272,7 @@ class TestHttpRunner(ApiServerUnittest):
|
|||||||
summary = runner.run("tests/httpbin/load_image.yml")
|
summary = runner.run("tests/httpbin/load_image.yml")
|
||||||
|
|
||||||
report_save_dir = os.path.join(os.getcwd(), 'reports', "demo")
|
report_save_dir = os.path.join(os.getcwd(), 'reports', "demo")
|
||||||
report_path = report.render_html_report(summary, report_dir=report_save_dir)
|
report_path = report.gen_html_report(summary, report_dir=report_save_dir)
|
||||||
self.assertTrue(os.path.isfile(report_path))
|
self.assertTrue(os.path.isfile(report_path))
|
||||||
shutil.rmtree(report_save_dir)
|
shutil.rmtree(report_save_dir)
|
||||||
|
|
||||||
@@ -569,7 +569,7 @@ class TestHttpRunner(ApiServerUnittest):
|
|||||||
"testcases": testcases
|
"testcases": testcases
|
||||||
}
|
}
|
||||||
summary = self.runner.run(tests_mapping)
|
summary = self.runner.run(tests_mapping)
|
||||||
report_path = report.render_html_report(summary)
|
report_path = report.gen_html_report(summary)
|
||||||
with open(report_path) as f:
|
with open(report_path) as f:
|
||||||
content = f.read()
|
content = f.read()
|
||||||
m = re.findall(
|
m = re.findall(
|
||||||
|
|||||||
Reference in New Issue
Block a user