mirror of
https://github.com/httprunner/httprunner.git
synced 2026-07-08 07:51:25 +08:00
feat: add json schema validation for testcase v2
This commit is contained in:
@@ -5,6 +5,7 @@
|
|||||||
**Added**
|
**Added**
|
||||||
|
|
||||||
- feat: add json schema validation for api
|
- feat: add json schema validation for api
|
||||||
|
- feat: add json schema validation for testcase v2
|
||||||
|
|
||||||
**Changed**
|
**Changed**
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import importlib
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
from httprunner import exceptions, logger, utils
|
from httprunner import exceptions, logger, utils
|
||||||
from httprunner.loader.check import JsonSchemaChecker
|
from httprunner.loader.check import JsonSchemaChecker, JsonSchemaV2Checker
|
||||||
from httprunner.loader.load import load_module_functions, load_file, load_dot_env_file, \
|
from httprunner.loader.load import load_module_functions, load_file, load_dot_env_file, \
|
||||||
load_folder_files
|
load_folder_files
|
||||||
from httprunner.loader.locate import init_project_working_directory, get_project_working_directory
|
from httprunner.loader.locate import init_project_working_directory, get_project_working_directory
|
||||||
@@ -225,6 +225,7 @@ def load_testcase_v2(raw_testcase):
|
|||||||
}
|
}
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
JsonSchemaV2Checker.validate_testcase_format(raw_testcase)
|
||||||
raw_teststeps = raw_testcase.pop("teststeps")
|
raw_teststeps = raw_testcase.pop("teststeps")
|
||||||
raw_testcase["teststeps"] = [
|
raw_testcase["teststeps"] = [
|
||||||
load_teststep(teststep)
|
load_teststep(teststep)
|
||||||
|
|||||||
@@ -2,23 +2,6 @@
|
|||||||
"$schema": "http://json-schema.org/draft-07/schema",
|
"$schema": "http://json-schema.org/draft-07/schema",
|
||||||
"description": "httprunner testcase schema definition",
|
"description": "httprunner testcase schema definition",
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
|
||||||
"config": {
|
|
||||||
"$ref": "common.schema.json#/definitions/config"
|
|
||||||
},
|
|
||||||
"teststeps": {
|
|
||||||
"description": "teststep of a testcase",
|
|
||||||
"type": "array",
|
|
||||||
"minItems": 1,
|
|
||||||
"items": {
|
|
||||||
"$ref": "#/definitions/teststep"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"required": [
|
|
||||||
"config",
|
|
||||||
"teststeps"
|
|
||||||
],
|
|
||||||
"definitions": {
|
"definitions": {
|
||||||
"teststep": {
|
"teststep": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
@@ -84,5 +67,22 @@
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
"properties": {
|
||||||
|
"config": {
|
||||||
|
"$ref": "common.schema.json#/definitions/config"
|
||||||
|
},
|
||||||
|
"teststeps": {
|
||||||
|
"description": "teststep of a testcase",
|
||||||
|
"type": "array",
|
||||||
|
"minItems": 1,
|
||||||
|
"items": {
|
||||||
|
"$ref": "testcase.schema.v2.json#/definitions/teststep"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"config",
|
||||||
|
"teststeps"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user