Metadata-Version: 2.1
Name: behave-db
Version: 0.0.5
Summary: BDD DB steps implementation for Behave
Home-page: https://github.com/M-halliday/behave-db
License: BSD
Keywords: BDD,Behavior-Driven-Development,DB
Author: zmr
Author-email: zmr_01@126.com
Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*, !=3.6.*
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: Other/Proprietary License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Software Development :: Quality Assurance
Classifier: Topic :: Software Development :: Testing
Requires-Dist: JayDeBeApi (>=1.2.3,<2.0.0)
Requires-Dist: behave (>=1.2.6,<2.0.0)
Project-URL: Repository, https://github.com/M-halliday/behave-db
Description-Content-Type: text/markdown

# behave-db
BDD DB steps implementation for Behave

_behave-db_ is a db testing tools for
Behavior-Driven-Development, based on
[behave](http://pypi.python.org/pypi/behave) and
[JayDeBeApi](https://github.com/baztian/jaydebeapi).



## Installation 

You can get and install behave-db with pip

```
$ pip install  behave-db
```

## Usage example

*yourapp/features/environment.py*:

```python
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*:

```python
from behave_db.steps import *
```

*yourapp/features/some\_db.feature*:

```gherkin
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*:

```shell
$ ls

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

```

*run in yourapp/*:

``` python
# 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

```

## other tools on behave

*web application testing*

[behaving](https://github.com/ggozad/behaving)

*api testing*

[behave-http](https://github.com/mikek/behave-http)



