Giter VIP home page Giter VIP logo

jsonschema-test's Introduction

JSON Schema Testing

Build Status

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.

Installation

pip install jsonschema-test

Usage

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.

Example

Test Suite

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
            }
        ]
    }
]

Schema

A JSON Schema to test.

{
    "type": "object",
    "properties": {
        "name": {
            "type": "string"
        }
    },
    "required": [ "name" ]
}

Running the tests

jsonschema-test example/schema.json example/tests.json

Test Suite Structure

There is a JSON Schema file for the test suite structure.

Suite

A test suite is a logical group of Test's. It's a simple JSON file with an array containing each test.

Test

Properties

  • 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.

Case

Properties

  • description (string, required) - The description of this test case.
  • data (any, required) - The JSON used against the JSON Schema.
  • valid (boolean, required) - If the data should validate or not.
  • skip (boolean, optional) - Whether to skip the case. This defaults to false.

Credits

This tool was built by Kyle Fuller (@kylefuller).

License

jsonschema-test is released under the BSD license. See LICENSE.

jsonschema-test's People

Contributors

kylef avatar

Stargazers

 avatar Angus H. avatar Alexis Métaireau avatar sota avatar Ananta Pandu Wicaksana avatar Gaspard avatar Boris Bügling avatar Ronak Jangir avatar Samuel Giddins avatar

Watchers

 avatar James Cloos avatar sota avatar  avatar

jsonschema-test's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.