A plugin for nose2 implementing behavior-driven testing.
Project description
A plugin for running behavior-driven tests using gherkin inside nose2.
Usage
To enable planterbox for your project, you’ll want to add the following lines (or similar) to your unittest.cfg:
[unittest]
plugins = planterbox
[planterbox]
always-on = True
planterbox is compatible with nose2.plugins.mp.
Writing Tests
planterbox tests exist inside a python package which provides a context or “world” for their execution. You should write your tests in .feature files in the package directory. .feature files have access to all steps defined in or imported into their package’s __init__.py. For example, with the directory structure:
planterbox/ tests/ test_feature/ __init__.py basic.feature
If __init__.py contains:
from planterbox import step
@step(r'I add (\d+) and (\d+)')
def add(test, a, b):
a = int(a)
b = int(b)
test.result = a + b
@step(r'the result should be (\d+)')
def check_result(test, value):
value = int(value)
test.assertEqual(test.result, value)
basic.feature could contain:
Feature: Basic Tests
I want to exercise generation of a simple test from a feature.
Scenario: I need to verify basic arithmetic.
Given I add 1 and 1
Then the result should be 2
We could then run this test either by running all of the tests in the suite with nose2 or run it specifically with nose2 planterbox.tests.test_feature:basic.feature. We could even run the first scenario specifically with nose2 planterbox.tests.test_feature:basic.feature:0.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file planterbox-0.3.tar.gz
.
File metadata
- Download URL: planterbox-0.3.tar.gz
- Upload date:
- Size: 8.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9d10d17b2b367444d219fc37537db17483d92cfe473029397af0dc22c20d9c3b |
|
MD5 | 26fdb73af43fbd9026066397c978b2fc |
|
BLAKE2b-256 | 86a70148003a1fb635966b67c5561d07f115d4ea372cfdc92ab0e12c2cbaf040 |
File details
Details for the file planterbox-0.3-py2-none-any.whl
.
File metadata
- Download URL: planterbox-0.3-py2-none-any.whl
- Upload date:
- Size: 10.3 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 43f6f81cc2c0d16dd609161080725beafb8c3554c72b2afd74829a26407e54db |
|
MD5 | d38f837e10d9bfccac01711cc1395476 |
|
BLAKE2b-256 | 815158e2a142b83bd51052c5abbfcb2333f74db2843e4a4d275508c8f29f6a28 |