All Projects → behave-restful → behave-restful

behave-restful / behave-restful

Licence: MIT License
BDD Framework to Test REST Services and APIs

Programming Languages

python
139335 projects - #7 most used programming language
Gherkin
971 projects

Projects that are alternatives of or similar to behave-restful

Karate
Test Automation Made Simple
Stars: ✭ 5,497 (+11595.74%)
Mutual labels:  bdd, gherkin, testing-tools
karate-runner
VSCode Extension for Karate
Stars: ✭ 23 (-51.06%)
Mutual labels:  bdd, gherkin, testing-tools
kheera-testrunner-android
BDD Framework for Android
Stars: ✭ 18 (-61.7%)
Mutual labels:  bdd, gherkin, testing-tools
bat
Gherkin based DSL for testing HTTP APIs via Cucumber.JS
Stars: ✭ 30 (-36.17%)
Mutual labels:  bdd, gherkin, testing-tools
scenari
Clojure BDD library - Executable Specification with Behavior-Driven Development
Stars: ✭ 57 (+21.28%)
Mutual labels:  bdd, gherkin
cucumber-jvm-examples
Cucumber-jvm 5.0.0 examples with Maven
Stars: ✭ 20 (-57.45%)
Mutual labels:  bdd, gherkin
Awesome-Cucumber
A collection of awesome Cucumber and Gherkin-related resources
Stars: ✭ 33 (-29.79%)
Mutual labels:  bdd, gherkin
gavel-spec
Behavior specification for Gavel, validator of HTTP transactions
Stars: ✭ 105 (+123.4%)
Mutual labels:  bdd, gherkin
karate
Test Automation Made Simple
Stars: ✭ 6,384 (+13482.98%)
Mutual labels:  bdd, testing-tools
REST-Api-with-Slim-PHP
REST API with PHP Slim Framework 3 and MySQL
Stars: ✭ 69 (+46.81%)
Mutual labels:  restful-api, restful-webservices
poco restful webservice
A RESTful API using Poco C++ Libraries.
Stars: ✭ 54 (+14.89%)
Mutual labels:  restful-api, restful-webservices
cucumber-performance
A performance testing framework for cucumber
Stars: ✭ 28 (-40.43%)
Mutual labels:  bdd, gherkin
featurebook
A command line tool (and Node.js library) for generating beautiful system specifications from Gherkin source files.
Stars: ✭ 40 (-14.89%)
Mutual labels:  bdd, gherkin
mocha-cakes-2
A BDD plugin for Mocha testing framework
Stars: ✭ 44 (-6.38%)
Mutual labels:  bdd, gherkin
nanoFramework.WebServer
📦 Web server for nanoFramework packed with features: REST api using attributes, multithread requests, parameters in query URL, static files serving.
Stars: ✭ 15 (-68.09%)
Mutual labels:  restful-api, restful-webservices
orion
A next-generation testing tool. Orion provides a powerful DSL to write and automate your acceptance tests
Stars: ✭ 40 (-14.89%)
Mutual labels:  bdd, testing-tools
showroom
Universal development and automated test environment for web components
Stars: ✭ 89 (+89.36%)
Mutual labels:  bdd, testing-tools
aloe
Behavior Driven Development using Cucumber for Python
Stars: ✭ 63 (+34.04%)
Mutual labels:  bdd, gherkin
cucumber6-ts-starter
Starter project to write and debug cucumber-js features in TypeScript language
Stars: ✭ 62 (+31.91%)
Mutual labels:  bdd, gherkin
RestSharpFramework
Framework for testing RESTful Services with RestSharp and C# HTTP Client
Stars: ✭ 18 (-61.7%)
Mutual labels:  restful-api, restful-webservices

Behave Restful

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

Installation

Use pip to install behave-restful in your project

pip install behave-restful

Setup

To add support for behave-restful steps in your .feature files, you need to include behave-restful's environment and step definitions.

You can do this simply by adding two boilerplate files to your project:

In the root of your features directory, add this environment.py file:

# {your_project}/features/en/__init__.py

import os

import behave_restful.app as br_app


def before_all(context):
    this_directory = os.path.abspath(os.path.dirname(__file__))
    br_app.BehaveRestfulApp().initialize_context(context, this_directory)
    context.hooks.invoke(br_app.BEFORE_ALL, context)


def after_all(context):
    context.hooks.invoke(br_app.AFTER_ALL, context)


def before_feature(context, feature):
    context.hooks.invoke(br_app.BEFORE_FEATURE, context, feature)


def after_feature(context, feature):
    context.hooks.invoke(br_app.AFTER_FEATURE, context, feature)


def before_scenario(context, scenario):
    context.hooks.invoke(br_app.BEFORE_SCENARIO, context, scenario)


def after_scenario(context, scenario):
    context.hooks.invoke(br_app.AFTER_SCENARIO, context, scenario)


def before_step(context, step):
    context.hooks.invoke(br_app.BEFORE_STEP, context, step)


def after_step(context, step):
    context.hooks.invoke(br_app.AFTER_STEP, context, step)


def before_tag(context, tag):
    context.hooks.invoke(br_app.BEFORE_TAG, context, tag)


def after_tag(context, tag):
    context.hooks.invoke(br_app.AFTER_TAG, context, tag)

And under features/steps add this __init__.py file:

# {your_project}/features/steps/__init__.py
from behave_restful.lang import *
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].