feat: add json schema validation for testcase v2

This commit is contained in:
debugtalk
2019-12-31 18:27:58 +08:00
parent 36dd21fe2b
commit 4f06ca3cd1
3 changed files with 21 additions and 19 deletions

View File

@@ -5,6 +5,7 @@
**Added**
- feat: add json schema validation for api
- feat: add json schema validation for testcase v2
**Changed**

View File

@@ -2,7 +2,7 @@ import importlib
import os
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, \
load_folder_files
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_testcase["teststeps"] = [
load_teststep(teststep)

View File

@@ -2,23 +2,6 @@
"$schema": "http://json-schema.org/draft-07/schema",
"description": "httprunner testcase schema definition",
"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": {
"teststep": {
"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"
]
}