mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-05 15:37:35 +08:00
Merge pull request #856 from httprunner/leo_dev
2.5.6 **Fixed** - fix: abort test when failed to parse all cases - fix: log error when parse failed
This commit is contained in:
+11
-2
@@ -1,10 +1,19 @@
|
|||||||
# Release History
|
# Release History
|
||||||
|
|
||||||
## 2.5.6 (2020-02-05)
|
## 2.5.6 (2020-02-19)
|
||||||
|
|
||||||
**Added**
|
**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)
|
## 2.5.5 (2020-01-06)
|
||||||
|
|
||||||
|
|||||||
+6
-2
@@ -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.
|
""" initialize HttpRunner.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -200,6 +200,10 @@ class HttpRunner(object):
|
|||||||
logger.log_warning("parse failures occurred ...")
|
logger.log_warning("parse failures occurred ...")
|
||||||
utils.dump_logs(parse_failed_testfiles, project_mapping, "parse_failed")
|
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:
|
if self.save_tests:
|
||||||
utils.dump_logs(parsed_testcases, project_mapping, "parsed")
|
utils.dump_logs(parsed_testcases, project_mapping, "parsed")
|
||||||
|
|
||||||
@@ -223,7 +227,7 @@ class HttpRunner(object):
|
|||||||
utils.dump_logs(self._summary, project_mapping, "summary")
|
utils.dump_logs(self._summary, project_mapping, "summary")
|
||||||
# save variables and export data
|
# save variables and export data
|
||||||
vars_out = self.get_vars_out()
|
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
|
return self._summary
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,10 @@ class MyBaseFailure(Exception):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class ParseTestsFailure(MyBaseFailure):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class ValidationFailure(MyBaseFailure):
|
class ValidationFailure(MyBaseFailure):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import multiprocessing
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
from httprunner import __version__
|
||||||
from httprunner import logger
|
from httprunner import logger
|
||||||
from httprunner.utils import init_sentry_sdk
|
from httprunner.utils import init_sentry_sdk
|
||||||
|
|
||||||
@@ -104,6 +105,7 @@ def run_locusts_with_processes(sys_argv, processes_count):
|
|||||||
def main():
|
def main():
|
||||||
""" Performance test with locust: parse command line options and run commands.
|
""" Performance test with locust: parse command line options and run commands.
|
||||||
"""
|
"""
|
||||||
|
print("HttpRunner version: {}".format(__version__))
|
||||||
sys.argv[0] = 'locust'
|
sys.argv[0] = 'locust'
|
||||||
if len(sys.argv) == 1:
|
if len(sys.argv) == 1:
|
||||||
sys.argv.extend(["-h"])
|
sys.argv.extend(["-h"])
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import json
|
|||||||
import re
|
import re
|
||||||
|
|
||||||
from httprunner import exceptions, utils, loader
|
from httprunner import exceptions, utils, loader
|
||||||
|
from httprunner import logger
|
||||||
from httprunner.compat import basestring, numeric_types, str
|
from httprunner.compat import basestring, numeric_types, str
|
||||||
|
|
||||||
# use $$ to escape $ notation
|
# use $$ to escape $ notation
|
||||||
@@ -1242,10 +1243,12 @@ def _parse_testcase(testcase, project_mapping, session_variables_set=None):
|
|||||||
"config": prepared_config,
|
"config": prepared_config,
|
||||||
"teststeps": prepared_testcase_tests
|
"teststeps": prepared_testcase_tests
|
||||||
}
|
}
|
||||||
except (exceptions.MyBaseFailure, exceptions.MyBaseError):
|
except (exceptions.MyBaseFailure, exceptions.MyBaseError) as ex:
|
||||||
testcase_type = testcase["type"]
|
testcase_type = testcase["type"]
|
||||||
testcase_path = testcase.get("path")
|
testcase_path = testcase.get("path")
|
||||||
|
|
||||||
|
logger.log_error("failed to parse testcase: {}, error: {}".format(testcase_path, ex))
|
||||||
|
|
||||||
global parse_failed_testfiles
|
global parse_failed_testfiles
|
||||||
if testcase_type not in parse_failed_testfiles:
|
if testcase_type not in parse_failed_testfiles:
|
||||||
parse_failed_testfiles[testcase_type] = []
|
parse_failed_testfiles[testcase_type] = []
|
||||||
|
|||||||
Reference in New Issue
Block a user