fix: handle errors when no valid testcases generated

This commit is contained in:
debugtalk
2020-05-18 11:25:49 +08:00
parent 718fea62e0
commit a17ff355a2
3 changed files with 12 additions and 3 deletions

View File

@@ -5,6 +5,7 @@
**Fixed**
- fix: extract response cookies
- fix: handle errors when no valid testcases generated
## 3.0.3 (2020-05-17)

View File

@@ -3,6 +3,7 @@ import os
import sys
import pytest
from loguru import logger
from httprunner import __description__, __version__, exceptions
from httprunner.ext.har2case import init_har2case_parser, main_har2case
@@ -33,7 +34,10 @@ def main_run(extra_args):
# has not specified any testcase path
raise exceptions.ParamsError("Missed testcase path")
main_make(tests_path_list)
testcase_path_list = main_make(tests_path_list)
if not testcase_path_list:
logger.error("No valid testcases found, exit 1.")
sys.exit(1)
if "-s" not in extra_args:
extra_args.insert(0, "-s")

View File

@@ -89,7 +89,7 @@ def format_with_black(tests_path: Text):
logger.error(ex)
def make(tests_path: Text) -> List:
def __make(tests_path: Text) -> List:
testcases = []
if os.path.isdir(tests_path):
files_list = load_folder_files(tests_path)
@@ -106,6 +106,10 @@ def make(tests_path: Text) -> List:
continue
testcase_path_list.append(testcase_path)
if not testcase_path_list:
logger.warning(f"No valid testcase generated on {tests_path}")
return []
format_with_black(tests_path)
return testcase_path_list
@@ -113,7 +117,7 @@ def make(tests_path: Text) -> List:
def main_make(tests_paths: List[Text]) -> List:
testcase_path_list = []
for tests_path in tests_paths:
testcase_path_list.extend(make(tests_path))
testcase_path_list.extend(__make(tests_path))
return testcase_path_list