Skip to main content

Implements Gherking language for REST services.

Project description

Build Status

Behave Restful is a Behavior Driven Development (BDD) framework based on behave, that implements a language suitable to test and validate REST APIs and Services. It leverages the power of the gherkin language to write business readable tests that validate the behavior of REST APIs.

Although, Behave Restful is implemented in python and uses behave as underlying framework, it can test services implemented in any language as easy as:

Feature: API to add a new book to our collection
    As a user, I want to add a new book to my "to-read" collection.

    Scenario: Add a new book to collection.
        Given a request url http://my.reads/api/books
            And a request json payload
                """
                {
                    "category": "reference",
                    "author": "Nigel Rees",
                    "title": "Sayings of the Century",
                    "price": 8.95,
                    "status": "to-read"
                }
                """
        When the request sends POST
        Then the response status is CREATED
            And the response json matches
                """
                {
                    "title": "BookObject",
                    "type": "object"
                    "properties": {
                        "id": {"type": "number"},
                        "category": {"type": "string"},
                        "author": {"type": "string"},
                        "title": {"type": "string"},
                        "price": {"type": "number"},
                        "status": {"type": "string", "enum": ["to-read", "reading", "read"]}
                    },
                    "required": ["id", "category", "title"]
                }
                """
            And the response json at $.id is equal to 100
            And the response json at $.category is equal to "reference"
            And the response json at $.title is equal to "Sayings of the Century"

As you can see in the example, we send a POST request to the specified url with a JSON payload, and we can validate the result very easy. First, we verify that the status of the response is CREATED (it succeeds). Then we validate the response JSON body using the expected JSON Schema. Finally, we validate specific values in the response using JSONPath

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

behave_restful-0.1.7-py2.py3-none-any.whl (14.0 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page