Skip to main content

BDD DB steps implementation for Behave

Project description

behave-db

BDD DB steps implementation for Behave

behave-db is a db testing tools for Behavior-Driven-Development, based on behave and JayDeBeApi.

Installation

You can get and install behave-db with pip

$ pip install  behave-db

Usage example

yourapp/features/environment.py:

from behave_db import environment as benv

def before_all(context):
    import behave_db
    config_datas = {}
    #jdbc-drivers in data_dir
    data_dir = os.path.join(
        os.path.dirname(behave_db.__file__), "../../tests/data"
    )
    #set csv-jdbc-config
    config_datas['driver_name'] = "org.relique.jdbc.csv.CsvDriver"
    config_datas['driver_jar_path'] = os.path.join(data_dir,"drivers","csvjdbc-1.0-37.jar")
    config_datas['csv_jdbc_url'] = "jdbc:relique:csv:" + data_dir
    config_datas['db_user'] = None
    config_datas['db_password'] = None
    #copy var to behave_db
    benv.before_all(context)
    context.db_config = config_datas


def after_scenario(context, scenario):
    # auto close connect
    context.execute_steps(u"""
                 When I close the connect
                """)

yourapp/features/steps/some_db_stuff.py:

from behave_db.steps import *

yourapp/features/some_db.feature:

Feature: databases testing
    testing behave-db steps

    Scenario: connect to csv with var 
        Given I connect to db "$csv_jdbc_url" with user "$db_user" and password "$db_password"
        When I wait for 1 seconds
        Then I set "count_num" from the search with "SELECT count(1) FROM csv_datas "
        And  the "$count_num" is not null
        And  the "$count_num" value should be "200"

yourapp/data/some_db_jdbc.jar:

$ ls

csvjdbc-1.0-37.jar
...
...

run in yourapp/:

# run behave in yourapp dir

E:\git-code\behave-db\tests>behave

Feature: databases testing # features/basic.feature:1
  testing behave-db steps
  Scenario: connect to csv with var                                                        # features/basic.feature:4
    Given I connect to db "$csv_jdbc_url" with user "$db_user" and password "$db_password" # ../src/behave_db/steps/basic.py:12
    When I wait for 1 seconds                                                              # ../src/behave_db/steps/basic.py:53
    Then I set "count_num" from the search with "SELECT count(1) FROM csv_datas "          # ../src/behave_db/steps/basic.py:59
    And the "$count_num" is not null                                                       # ../src/behave_db/steps/basic.py:68
    And the "$count_num" value should be "200"                                             # features/steps/steps.py:8

1 feature passed, 0 failed, 0 skipped
1 scenarios passed, 0 failed, 0 skipped
5 steps passed, 0 failed, 0 skipped, 0 undefined
Took 0m1.797s

TODO

  1. drop、delete、insert... or other common steps
  2. build on docker

other tools on behave

web application testing behaving

api testing behave-http

Project details


Download files

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

Source Distribution

behave-db-0.0.6.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

behave_db-0.0.6-py2.py3-none-any.whl (5.2 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file behave-db-0.0.6.tar.gz.

File metadata

  • Download URL: behave-db-0.0.6.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.6 CPython/3.8.10 Windows/10

File hashes

Hashes for behave-db-0.0.6.tar.gz
Algorithm Hash digest
SHA256 1068627843e925ce33238c8e1d0e7ded85e660d30c182308a4d68a7304bce298
MD5 7f880c9cb2ca077a1cffc220795fa0cd
BLAKE2b-256 dc20b2bdd8022de6b689904ac6bbd99bd9309d3d42bafb4612568f25ec3e851e

See more details on using hashes here.

File details

Details for the file behave_db-0.0.6-py2.py3-none-any.whl.

File metadata

  • Download URL: behave_db-0.0.6-py2.py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.6 CPython/3.8.10 Windows/10

File hashes

Hashes for behave_db-0.0.6-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 ff393c208ae7b6f10740d0a1da0ae32a2f94443557c97bebd65837ff2ea26d33
MD5 c673e4e97847a908e2c9c78bde7b7606
BLAKE2b-256 387a6699d24867011ad4238847bc282bd5bf01a4b7584d8a8d5c0b2ed3e05100

See more details on using hashes here.

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