jsonschema-test is a tool for writing and running tests against a given JSON Schema. You can write a set of test-cases including example JSON values and if they should validate or not against the given JSON Schema.
pip install jsonschema-test
To use jsonschema-test, you will need to write a collection of tests. The tests are decoupled from any language and are written in JSON.
A test suite is a collection of test's and test cases. See the test suite structure for more information
[
{
"description": "a person",
"tests": [
{
"description": "validates with a name",
"data": {
"name": "Kyle"
},
"valid": true
},
{
"description": "fails validation without a name",
"data": {
},
"valid": false
}
]
}
]
A JSON Schema to test.
{
"type": "object",
"properties": {
"name": {
"type": "string"
}
},
"required": [ "name" ]
}
jsonschema-test example/schema.json example/tests.json
There is a JSON Schema file for the test suite structure.
A test suite is a logical group of Test's. It's a simple JSON file with an array containing each test.
description
(string, required) - A short description of what this test tests.tests
(array[Case], required) - A collection of test cases.skip
(boolean, optional) - Whether to skip the test. This defaults to false.
description
(string, required) - The description of this test case.data
(any, required) - The JSON used against the JSON Schema.valid
(boolean, required) - If thedata
should validate or not.skip
(boolean, optional) - Whether to skip the case. This defaults to false.
This tool was built by Kyle Fuller (@kylefuller).
jsonschema-test is released under the BSD license. See LICENSE.