From c6fb1e5af86e20b32d16f0cbc90e494f966f8a6f Mon Sep 17 00:00:00 2001 From: debugtalk Date: Wed, 19 Feb 2020 12:00:03 +0800 Subject: [PATCH] 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