Implements Gherking language for REST services.
Project description
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Hashes for behave_restful-0.1.8-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dad198f90932ab52e08894bf6979422d8cf68c12f03ee380959cda21d2f3b22a |
|
MD5 | 27b3878a414878b577a946b3e8581666 |
|
BLAKE2b-256 | 272b3b3a136722546d8949b5a807859bc4318f29f82d7526b3207e9476f99769 |