GithubHelp home page GithubHelp logo

jonathanmilliere / behave-rest Goto Github PK

View Code? Open in Web Editor NEW

This project forked from stanfy/behave-rest

0.0 2.0 0.0 34 KB

BDD-style Rest API testing tool

License: Apache License 2.0

Python 83.82% Gherkin 16.18%

behave-rest's Introduction

behave-rest

BDD-style Rest API testing tool

It uses python's requests for performing HTTP requests, nose for most assertions, trafaret for json validation and behave for BDD style of tests.

Installation

Run pip install behave_rest to download package and install required dependencies

OR

Clone project

Run pip install -r requirements.txt to install required dependencies

Running

# to execute all feature files (all tests)
behave

# to execture specific feature
behave features/twitter.feature

# to see printed output add --no-capture
behave --no-capture

# run features with specific tags
behave --tags=without_login --tags=slow

More about behave tool you can read here https://pythonhosted.org/behave/index.html

Test example

Feature: Twitter search

  Background: Setup environment
    Given I set base URL to "https://api.twitter.com/1.1/search"
    And I set "Authorization" header to "context.twitter_auth"
  
  Scenario: Search for tweets
    When I make a GET request to "tweets.json" with parameters
    |q|
    |stanfy|
    Then the response status code should equal 200
    And the response structure should equal "twitterSearchData"
    And the response header "status" should equal "200 OK"

CI reports

Behave support JUnit reports, that are easily parsed by CI tools

To enable JUnit reports, create behave.ini file:

[behave]
junit=true

Reports are generated into /reports folder

Another useful options to add into behave.ini are:

stdout_capture=False to add printed output into reports

show_timings=no to hide timing of each step

Step descriptions

Wiki page

SSL validation

By default, requests has a turned on SSL validation. This can be turned off globally, by setting context.verify_ssl = True in environment.py, or by using steps described in Wiki page

Project Structure

Feature files are intended to locate in /features folder

Corresponding steps are located in /features/steps

Overall project structure is as follows:

+-- requirements.txt // store python requirements

+-- behave_rest/
    
    +-- environment.py // contains common actions related to scenarios (e.g. clearting headers after running each feature file)

    +-- steps/

        +-- __init__.py // contains common steps definitions

+-- features/

    +-- conf.yaml // store project config (urls, global variables, etc.)

    +-- environment.py // context setup steps (e.g. load from config)

    +-- *.feature // feature files

    +-- steps/

        +-- __init__.py // used to import predefined steps

        +-- json_responses.py // response structures described in Trafaret format

        +-- *.py // steps related to corresponding feature (e.g. "login.py" contains steps that are related to "login.feature")  
        

behave-rest's People

Contributors

jonathanmilliere avatar paultaykalo avatar

Watchers

James Cloos 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.