From 57c18f0c25783fcf789d90bfbd0b16b0b9822f4d Mon Sep 17 00:00:00 2001 From: debugtalk Date: Wed, 5 Feb 2020 12:43:54 +0800 Subject: [PATCH 1/6] change: save variables and export data to xx.io.json --- httprunner/api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httprunner/api.py b/httprunner/api.py index bc13fc81..1edc1dcc 100644 --- a/httprunner/api.py +++ b/httprunner/api.py @@ -223,7 +223,7 @@ class HttpRunner(object): utils.dump_logs(self._summary, project_mapping, "summary") # save variables and export data vars_out = self.get_vars_out() - utils.dump_logs(vars_out, project_mapping, "vars_out") + utils.dump_logs(vars_out, project_mapping, "io") return self._summary From 15ecca3ef26efdaf0ae9afb46e0b5e336067a1d6 Mon Sep 17 00:00:00 2001 From: debugtalk Date: Wed, 5 Feb 2020 20:29:39 +0800 Subject: [PATCH 2/6] change: alter HttpRunner default log_level to WARNING --- docs/CHANGELOG.md | 4 ++++ httprunner/api.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 7caaa220..e3a6a8f0 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -6,6 +6,10 @@ - feat: save variables and export data to JSON files when specified `--save-tests` +**Changed** + +- change: alter HttpRunner default log_level to WARNING + ## 2.5.5 (2020-01-06) **Fixed** diff --git a/httprunner/api.py b/httprunner/api.py index 1edc1dcc..cdd7bd32 100644 --- a/httprunner/api.py +++ b/httprunner/api.py @@ -22,7 +22,7 @@ class HttpRunner(object): """ - def __init__(self, failfast=False, save_tests=False, log_level="INFO", log_file=None): + def __init__(self, failfast=False, save_tests=False, log_level="WARNING", log_file=None): """ initialize HttpRunner. Args: From 56a5b40ba7ec39b33b051c5bba8c5b8f39da2d44 Mon Sep 17 00:00:00 2001 From: debugtalk Date: Thu, 6 Feb 2020 16:02:43 +0800 Subject: [PATCH 3/6] feat: print HttpRunner version when executing locusts --- httprunner/ext/locusts/cli.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/httprunner/ext/locusts/cli.py b/httprunner/ext/locusts/cli.py index 90a99a39..24e54abf 100644 --- a/httprunner/ext/locusts/cli.py +++ b/httprunner/ext/locusts/cli.py @@ -18,6 +18,7 @@ import multiprocessing import os import sys +from httprunner import __version__ from httprunner import logger from httprunner.utils import init_sentry_sdk @@ -104,6 +105,7 @@ def run_locusts_with_processes(sys_argv, processes_count): def main(): """ Performance test with locust: parse command line options and run commands. """ + print("HttpRunner version: {}".format(__version__)) sys.argv[0] = 'locust' if len(sys.argv) == 1: sys.argv.extend(["-h"]) From a1d1f2d1864c6584e093f0dbac059c33ac6b1c9b Mon Sep 17 00:00:00 2001 From: debugtalk Date: Wed, 19 Feb 2020 11:41:15 +0800 Subject: [PATCH 4/6] fix: log error when parse failed --- httprunner/parser.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/httprunner/parser.py b/httprunner/parser.py index 8fc49d8e..f1600d39 100644 --- a/httprunner/parser.py +++ b/httprunner/parser.py @@ -7,6 +7,7 @@ import json import re from httprunner import exceptions, utils, loader +from httprunner import logger from httprunner.compat import basestring, numeric_types, str # use $$ to escape $ notation @@ -1242,10 +1243,12 @@ def _parse_testcase(testcase, project_mapping, session_variables_set=None): "config": prepared_config, "teststeps": prepared_testcase_tests } - except (exceptions.MyBaseFailure, exceptions.MyBaseError): + except (exceptions.MyBaseFailure, exceptions.MyBaseError) as ex: testcase_type = testcase["type"] testcase_path = testcase.get("path") + logger.log_error("failed to parse testcase: {}, error: {}".format(testcase_path, ex)) + global parse_failed_testfiles if testcase_type not in parse_failed_testfiles: parse_failed_testfiles[testcase_type] = [] From c6fb1e5af86e20b32d16f0cbc90e494f966f8a6f Mon Sep 17 00:00:00 2001 From: debugtalk Date: Wed, 19 Feb 2020 12:00:03 +0800 Subject: [PATCH 5/6] fix: abort test when failed to parse all cases --- httprunner/api.py | 4 ++++ httprunner/exceptions.py | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/httprunner/api.py b/httprunner/api.py index cdd7bd32..cb3c862b 100644 --- a/httprunner/api.py +++ b/httprunner/api.py @@ -200,6 +200,10 @@ class HttpRunner(object): logger.log_warning("parse failures occurred ...") utils.dump_logs(parse_failed_testfiles, project_mapping, "parse_failed") + if len(parsed_testcases) == 0: + logger.log_error("failed to parse all cases, abort.") + raise exceptions.ParseTestsFailure + if self.save_tests: utils.dump_logs(parsed_testcases, project_mapping, "parsed") diff --git a/httprunner/exceptions.py b/httprunner/exceptions.py index ad05ea53..17bd8ee1 100644 --- a/httprunner/exceptions.py +++ b/httprunner/exceptions.py @@ -11,6 +11,10 @@ class MyBaseFailure(Exception): pass +class ParseTestsFailure(MyBaseFailure): + pass + + class ValidationFailure(MyBaseFailure): pass From f1bb63fb052be27fda650c9e8d5180b316c56601 Mon Sep 17 00:00:00 2001 From: debugtalk Date: Wed, 19 Feb 2020 12:22:39 +0800 Subject: [PATCH 6/6] doc: update changelog --- docs/CHANGELOG.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index e3a6a8f0..ce18d14d 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,15 +1,20 @@ # Release History -## 2.5.6 (2020-02-05) +## 2.5.6 (2020-02-19) **Added** -- feat: save variables and export data to JSON files when specified `--save-tests` +- feat: save variables and export data to JSON files (named xx.io.json) when specified `--save-tests` **Changed** - change: alter HttpRunner default log_level to WARNING +**Fixed** + +- fix: abort test when failed to parse all cases +- fix: log error when parse failed + ## 2.5.5 (2020-01-06) **Fixed**