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 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.6.1.tar.gz (10.8 kB view details)

Uploaded Source

Built Distribution

planterbox-0.6.1-py2-none-any.whl (14.1 kB view details)

Uploaded Python 2

File details

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

File metadata

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

File hashes

Hashes for planterbox-0.6.1.tar.gz
Algorithm Hash digest
SHA256 81d9e47b1f6df7f02fcc58bc0863f01ce6cddb6733e54d9f6e2ba546e47ac5a0
MD5 d361e2f3fd5940debc521d70bdebec8c
BLAKE2b-256 b5333d91da5e52505a4fa4fa1693c0a41573d54e1f239a42e06ec27d01f08f93

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for planterbox-0.6.1-py2-none-any.whl
Algorithm Hash digest
SHA256 cb6aa5dd1180ae3575737a5c02f5d9d5cc250c67b7531a2307bfa228a2217f9e
MD5 e2441d36342bb1f0d7657c6f386a9d81
BLAKE2b-256 87c765752e20d3ea1fea09a030e9930c51da365e46f6f60ce98434eaecd9b842

See more details on using hashes here.

Provenance

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