Skip to main content

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


Download files

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

Source Distribution

planterbox-0.2.1.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

planterbox-0.2.1-py2-none-any.whl (9.4 kB view details)

Uploaded Python 2

File details

Details for the file planterbox-0.2.1.tar.gz.

File metadata

  • Download URL: planterbox-0.2.1.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for planterbox-0.2.1.tar.gz
Algorithm Hash digest
SHA256 f15d9737fd1e52018f7c3851cc8b41db6fa1899ee9b5c91c7be3e8cf5651ec28
MD5 5aa1872fc02015eb3bd8d2bc0c22815c
BLAKE2b-256 58f5945d6d54f325b077ebf9401784abc76d139dce22dbf169fd58e0576c7db4

See more details on using hashes here.

File details

Details for the file planterbox-0.2.1-py2-none-any.whl.

File metadata

File hashes

Hashes for planterbox-0.2.1-py2-none-any.whl
Algorithm Hash digest
SHA256 f965cb44cdba7372e3dce253d91983b278a7c35dbf385c3ca11855898ef23bbd
MD5 20166e6539823ecc42269fe6730d4b33
BLAKE2b-256 8dbb4c9907d7699ea066dbb7249488a68d7f28e6caa01d3ddc76fd5d0f5e82d5

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