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
other tools on behave
web application testing
api testing
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.5.tar.gz
(4.8 kB
view details)
Built Distribution
File details
Details for the file behave-db-0.0.5.tar.gz
.
File metadata
- Download URL: behave-db-0.0.5.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.6 CPython/3.8.10 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 34f76c0e77cfc0f697d22a9fc9f2ae3503053f59d850a849f80474376d49112c |
|
MD5 | e8986e6778e234eb4a3a8337b0e5a39f |
|
BLAKE2b-256 | 6a82ed856b490d88e2541aa9018bacf21abd45fb5574f775e808ea9180fcb603 |
File details
Details for the file behave_db-0.0.5-py2.py3-none-any.whl
.
File metadata
- Download URL: behave_db-0.0.5-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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1cb8b9aee24da62503aad5015f916e3769402e3eda8bd836919b920ff11d6a76 |
|
MD5 | a3a630e40fe24434e755f92b9dd759c8 |
|
BLAKE2b-256 | 84668445272f8e9a3de878f88887b7e295be7d0781655abd71c9f98dd0e09f7e |