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
            },
            {
                "description": "Load a test from a file.",
                "file": true,
                "data": "mytest.json",
                "valid": true
            }
        ]
    }
]

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.

Case

Properties

  • description (string, required) - The description of this test case.
  • file (boolean, optional) - When true, indicate that the data property is a filepath to the test, rather than actual test data. The filepath is relative to the current test suite file.
  • data (any, required) - The JSON used against the JSON Schema or the filepath to the test file.
  • valid (boolean, required) - If the data should validate or not.

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 stkerr avatar

Watchers

 avatar  avatar

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.