behave-cucumber-matcher


Namebehave-cucumber-matcher JSON
Version 0.4.0 PyPI version JSON
download
home_page
SummaryBehave step matcher for Cucumber Expressions.
upload_time2024-03-18 23:28:16
maintainer
docs_urlNone
authorKieran Ryan
requires_python>=3.7
license
keywords
VCS
bugtrack_url
requirements behave cucumber-expressions
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Behave Cucumber Matcher

[![Release version](https://img.shields.io/badge/dynamic/json?color=green&label=version&query=%24.info.version&url=https%3A%2F%2Ftest.pypi.org%2Fpypi%2Fbehave-cucumber-matcher%2Fjson)](https://test.pypi.org/pypi/behave-cucumber-matcher)
[![License](https://img.shields.io/pypi/l/behave-cucumber-matcher.svg)](https://pypi.python.org/pypi/behave-cucumber-matcher)
[![Python versions](https://img.shields.io/pypi/pyversions/behave-cucumber-matcher.svg)](https://pypi.org/pypi/behave-cucumber-matcher)
![Supported platforms](https://img.shields.io/badge/platforms-macOS%20%7C%20Windows%20%7C%20Linux-green)
![Cucumber](https://img.shields.io/badge/cucumber-gray?style=flat&logo=cucumber)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)
[![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336)](https://pycqa.github.io/isort/)
![Pipeline status](https://github.com/kieran-ryan/behave-cucumber-matcher/actions/workflows/main.yml/badge.svg)

Behave step matcher for [Cucumber Expressions](https://github.com/cucumber/cucumber-expressions).

## Installation

`behave-cucumber-matcher` is available via [PyPI](https://pypi.org/project/behave_cucumber_matcher/):

```console
pip install behave-cucumber-matcher
```

## Usage

Import and specify the matcher inside `environment.py` of your `features` directory.

```python
from behave.matchers import use_step_matcher
from behave_cucumber_matcher import CUCUMBER_EXPRESSIONS_MATCHER

# Specify to use the Cucumber Expressions step matcher
use_step_matcher(CUCUMBER_EXPRESSIONS_MATCHER)
```

Create a scenario inside `color.feature` of your `features` directory:

```gherkin
Feature: Color selection

  Rule: User can select a profile color

    Scenario: User selects a valid color
      Given I am on the profile settings page
      When I select the theme colour "red"
      Then the profile colour should be "red"
```

Create step definitions inside `color.py` of your `features/steps` directory:

```python
from behave import given, then, when
from behave_cucumber_matcher import parameter_registry
from cucumber_expressions.parameter_type import ParameterType

# Define the parameter type
color = ParameterType(
    name="color",
    regexp="red|blue|yellow",
    type=str,
)

# Pass the parameter type to the registry instance
parameter_registry.define_parameter_type(color)

@given("I am on the profile customisation/settings page")
def step_given(context):
    assert True

# Reference the parameter type in the step definition pattern
@when('I select the theme colo(u)r "{color}"')
def step_when(context, selected_color):
    assert selected_color
    context.selected_color = selected_color

@then('the profile colo(u)r should be "{color}"')
def step_then(context, displayed_color):
    assert displayed_color
    assert context.selected_color == displayed_color
```

The necessary files are now in place to execute your gherkin scenario.

```console
repository/
  └── features/
      ├── steps/
      │   └── color.py
      ├── environment.py
      └── color.feature
```

Finally, execute Behave. The scenario will run with the step definitions using the Cucumber Expressions parameter type.

```console
$ behave
Feature: Color selection # features/color.feature:1
  Rule: User can select a profile color
  Scenario: User selects a valid color      # features/color.feature:5
    Given I am on the profile settings page # features/steps/color.py:20 0.000s
    When I select the theme colour "red"    # features/steps/color.py:26 0.000s
    Then the profile colour should be "red" # features/steps/color.py:32 0.000s

1 feature passed, 0 failed, 0 skipped
1 scenario passed, 0 failed, 0 skipped
3 steps passed, 0 failed, 0 skipped, 0 undefined
Took 0m0.001s
```

For detailed usage of _behave_, see the [official documentation](https://behave.readthedocs.io).

## Acknowledgements

Based on the Behave step matcher base class and built on the architecture of [cuke4behave](https://gitlab.com/cuke4behave/cuke4behave) by [Dev Kumar Gupta](https://github.com/mrkaiser), with extended type hints, a fix for detecting patterns without arguments, a default parameter type registry, additional documentation for arguments and return types, direct import of the matcher at package level rather than via its module, backwards compatibility with Cucumber Expressions missing parameter type defaults, and a global parameter type registry.

## License

`behave-cucumber-matcher` is licensed under the [MIT License](https://opensource.org/licenses/MIT)


            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "behave-cucumber-matcher",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "",
    "author": "Kieran Ryan",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/dd/78/e3c733da718faf37bb242473f2597dd98e74fe21cdc267fce83c010658a0/behave_cucumber_matcher-0.4.0.tar.gz",
    "platform": null,
    "description": "# Behave Cucumber Matcher\n\n[![Release version](https://img.shields.io/badge/dynamic/json?color=green&label=version&query=%24.info.version&url=https%3A%2F%2Ftest.pypi.org%2Fpypi%2Fbehave-cucumber-matcher%2Fjson)](https://test.pypi.org/pypi/behave-cucumber-matcher)\n[![License](https://img.shields.io/pypi/l/behave-cucumber-matcher.svg)](https://pypi.python.org/pypi/behave-cucumber-matcher)\n[![Python versions](https://img.shields.io/pypi/pyversions/behave-cucumber-matcher.svg)](https://pypi.org/pypi/behave-cucumber-matcher)\n![Supported platforms](https://img.shields.io/badge/platforms-macOS%20%7C%20Windows%20%7C%20Linux-green)\n![Cucumber](https://img.shields.io/badge/cucumber-gray?style=flat&logo=cucumber)\n[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)\n![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)\n[![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336)](https://pycqa.github.io/isort/)\n![Pipeline status](https://github.com/kieran-ryan/behave-cucumber-matcher/actions/workflows/main.yml/badge.svg)\n\nBehave step matcher for [Cucumber Expressions](https://github.com/cucumber/cucumber-expressions).\n\n## Installation\n\n`behave-cucumber-matcher` is available via [PyPI](https://pypi.org/project/behave_cucumber_matcher/):\n\n```console\npip install behave-cucumber-matcher\n```\n\n## Usage\n\nImport and specify the matcher inside `environment.py` of your `features` directory.\n\n```python\nfrom behave.matchers import use_step_matcher\nfrom behave_cucumber_matcher import CUCUMBER_EXPRESSIONS_MATCHER\n\n# Specify to use the Cucumber Expressions step matcher\nuse_step_matcher(CUCUMBER_EXPRESSIONS_MATCHER)\n```\n\nCreate a scenario inside `color.feature` of your `features` directory:\n\n```gherkin\nFeature: Color selection\n\n  Rule: User can select a profile color\n\n    Scenario: User selects a valid color\n      Given I am on the profile settings page\n      When I select the theme colour \"red\"\n      Then the profile colour should be \"red\"\n```\n\nCreate step definitions inside `color.py` of your `features/steps` directory:\n\n```python\nfrom behave import given, then, when\nfrom behave_cucumber_matcher import parameter_registry\nfrom cucumber_expressions.parameter_type import ParameterType\n\n# Define the parameter type\ncolor = ParameterType(\n    name=\"color\",\n    regexp=\"red|blue|yellow\",\n    type=str,\n)\n\n# Pass the parameter type to the registry instance\nparameter_registry.define_parameter_type(color)\n\n@given(\"I am on the profile customisation/settings page\")\ndef step_given(context):\n    assert True\n\n# Reference the parameter type in the step definition pattern\n@when('I select the theme colo(u)r \"{color}\"')\ndef step_when(context, selected_color):\n    assert selected_color\n    context.selected_color = selected_color\n\n@then('the profile colo(u)r should be \"{color}\"')\ndef step_then(context, displayed_color):\n    assert displayed_color\n    assert context.selected_color == displayed_color\n```\n\nThe necessary files are now in place to execute your gherkin scenario.\n\n```console\nrepository/\n  \u2514\u2500\u2500 features/\n      \u251c\u2500\u2500 steps/\n      \u2502   \u2514\u2500\u2500 color.py\n      \u251c\u2500\u2500 environment.py\n      \u2514\u2500\u2500 color.feature\n```\n\nFinally, execute Behave. The scenario will run with the step definitions using the Cucumber Expressions parameter type.\n\n```console\n$ behave\nFeature: Color selection # features/color.feature:1\n  Rule: User can select a profile color\n  Scenario: User selects a valid color      # features/color.feature:5\n    Given I am on the profile settings page # features/steps/color.py:20 0.000s\n    When I select the theme colour \"red\"    # features/steps/color.py:26 0.000s\n    Then the profile colour should be \"red\" # features/steps/color.py:32 0.000s\n\n1 feature passed, 0 failed, 0 skipped\n1 scenario passed, 0 failed, 0 skipped\n3 steps passed, 0 failed, 0 skipped, 0 undefined\nTook 0m0.001s\n```\n\nFor detailed usage of _behave_, see the [official documentation](https://behave.readthedocs.io).\n\n## Acknowledgements\n\nBased on the Behave step matcher base class and built on the architecture of [cuke4behave](https://gitlab.com/cuke4behave/cuke4behave) by [Dev Kumar Gupta](https://github.com/mrkaiser), with extended type hints, a fix for detecting patterns without arguments, a default parameter type registry, additional documentation for arguments and return types, direct import of the matcher at package level rather than via its module, backwards compatibility with Cucumber Expressions missing parameter type defaults, and a global parameter type registry.\n\n## License\n\n`behave-cucumber-matcher` is licensed under the [MIT License](https://opensource.org/licenses/MIT)\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Behave step matcher for Cucumber Expressions.",
    "version": "0.4.0",
    "project_urls": {
        "Changelog": "https://github.com/kieran-ryan/behave-cucumber-matcher/blob/main/CHANGELOG.md",
        "Documentation": "https://github.com/kieran-ryan/behave-cucumber-matcher/blob/main/README.md",
        "Source": "https://github.com/kieran-ryan/behave-cucumber-matcher",
        "Tracker": "https://github.com/kieran-ryan/behave-cucumber-matcher/issues"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b42124f8b8ef1d02336a827653d12350251e04f656c81312832096b321dd8501",
                "md5": "a14e2b305e6ea238c5d631a661d29248",
                "sha256": "f478175ba9a23ceef15cbf522cc98684540595bbbf60312579ac6f38a1060166"
            },
            "downloads": -1,
            "filename": "behave_cucumber_matcher-0.4.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a14e2b305e6ea238c5d631a661d29248",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 5937,
            "upload_time": "2024-03-18T23:28:14",
            "upload_time_iso_8601": "2024-03-18T23:28:14.966522Z",
            "url": "https://files.pythonhosted.org/packages/b4/21/24f8b8ef1d02336a827653d12350251e04f656c81312832096b321dd8501/behave_cucumber_matcher-0.4.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "dd78e3c733da718faf37bb242473f2597dd98e74fe21cdc267fce83c010658a0",
                "md5": "edd3af5a1112917436dd7c0e526a349c",
                "sha256": "b5e144974a059a57b1afb2b33649b4cc4c5364cd4a104d1f8098e7a36370c7a3"
            },
            "downloads": -1,
            "filename": "behave_cucumber_matcher-0.4.0.tar.gz",
            "has_sig": false,
            "md5_digest": "edd3af5a1112917436dd7c0e526a349c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 5201,
            "upload_time": "2024-03-18T23:28:16",
            "upload_time_iso_8601": "2024-03-18T23:28:16.546359Z",
            "url": "https://files.pythonhosted.org/packages/dd/78/e3c733da718faf37bb242473f2597dd98e74fe21cdc267fce83c010658a0/behave_cucumber_matcher-0.4.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-18 23:28:16",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "kieran-ryan",
    "github_project": "behave-cucumber-matcher",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "behave",
            "specs": [
                [
                    ">=",
                    "1.2.6"
                ]
            ]
        },
        {
            "name": "cucumber-expressions",
            "specs": [
                [
                    ">=",
                    "10.2.0"
                ]
            ]
        }
    ],
    "lcname": "behave-cucumber-matcher"
}
        
Elapsed time: 0.20352s