gherkin2robotframework


Namegherkin2robotframework JSON
Version 0.4.2 PyPI version JSON
download
home_pageNone
SummaryTranslate Gherkin feature files into RobotFramework tests
upload_time2024-11-16 12:08:22
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseThe MIT License (MIT) Copyright (c) 2016 mauricekoster Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords gherkin robotframework
VCS
bugtrack_url
requirements gherkin-official wheel
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # gherkin2robotframework

## Description

This tool can be used to facilitate the usage of Cucumber feature files in a RobotFramework Test Automation solution.
Although RobotFramework supports BDD style test cases, this support is limited to Given/When/Then keywords.
Features like datatables and docstrings are not supported in RobotFramework.
This tool will 'compile' Gherkin feature files into RobotFramework test cases and scaffolding for step definitions
aka User Keywords.

## Usage

### Example feature

```gherkin
Feature: Examples

  As a tester
  I want to specify feature files and translate it to RobotFramework
  So I can use the best of both worlds

  Background:
    Given some background stuff

  Scenario: Greeter
    Given a greeter
    When greeting the following persons:
      | Name  | Greeting   |
      | Joe   | Hello      |
      | Mary  | Hi, there! |
    Then the wold is a better place

  @tag
  Scenario Outline: Repetitive stuff
    A nice description
    on multiple lines
    Given a thing with "<thingy>"
    When some action
    Then this happened: <stuff>

    @A
    Examples: A
      Documentation for
      example A
      | thingy  | stuff |
      | AAA     | 123   |
      | BBB     | 456   |

    @B
    Examples: B
      Documentation for example B
      | thingy  | stuff |
      | CCC     | 789   |
      | DDD     | 000   |

  @tag
  Scenario Outline: More stuff
    A nice description
    on multiple lines
    Given a thing with "<thingy>"
    When doing action <action>
    Then this happened: <stuff>

    @A
    Examples: A
      Documentation for
      example A
      | thingy  | action | stuff |
      | AAA     | take   | 123   |
      | BBB     | give   | 456   |
```

### First time generation

After creating your feature files you can translate these into RobotFramework test scripts with the following command:

    gherkin2robotframework example.feature

Two files will be generated: *example.robot* containing the test cases and *example_step_definitions.robot* containing
the user keywords implement the steps. For the default english gherkins the Given/When/Then will be stripped
from the keyword names.

```robotframework: example.robot
*** Settings ***
Documentation    As a tester
...      I want to specify feature files and translate it to RobotFramework
...      So I can use the best of both worlds
Resource    ./examples_step_definitions.robot
Metadata    Feature    Examples
Metadata    Generated by    _gherkin2robotframework on 2020-01-31T13:23:34.958405_

*** Test Cases ***
Greeter
    Background
    Given a greeter
    ${DataTable}=    Create List
    FOR    ${Name}    ${Greeting}    IN
    ...    Joe    Hello
    ...    Mary    Hi, there!
        ${entry}=    Create Dictionary    Name=${Name}    Greeting=${Greeting}
        Append To List    ${DataTable}    ${entry}
    END
    When greeting the following persons:    @{DataTable}
    Then the wold is a better place

Repetitive stuff: A
    [Documentation]    Documentation for
    ...    example A
    [Tags]    tag    A
    [Template]    Scenario Outline Repetitive stuff
    AAA    123
    BBB    456

Repetitive stuff: B
    [Documentation]    Documentation for example B
    [Tags]    tag    B
    [Template]    Scenario Outline Repetitive stuff
    CCC    789
    DDD    000


*** Keywords ***
Background
    Given some background stuff

Scenario Outline Repetitive stuff
    [Documentation]    A nice description
    ...    on multiple lines
    [Arguments]    ${thingy}    ${stuff}
    Background
    Given a thing with "${thingy}"
    When some action
    Then this happened: ${stuff}

```

*example_step_definitions.robot*

```robotframework
*** Settings ***
Documentation    Generated by    _gherkin2robotframework on 2020-01-31T12:14:13.397524_
Library    Collections

*** Keywords ***
some background stuff
    Fail    Keyword "some background stuff" Not Implemented Yet

a greeter
    Fail    Keyword "a greeter" Not Implemented Yet

greeting the following persons:
    [Arguments]    @{DataTable}
    Fail    Keyword "greeting the following persons:" Not Implemented Yet

the wold is a better place
    Fail    Keyword "the wold is a better place" Not Implemented Yet

a thing with "${thingy}"
    Fail    Keyword "a thing with "${thingy}"" Not Implemented Yet

some action
    Fail    Keyword "some action" Not Implemented Yet

this happened: ${stuff}
    Fail    Keyword "this happened: ${stuff}" Not Implemented Yet

```

### Regeneration

In case your feature file is changed the .robot files needs to be regenerated.

```gherkin
...
    Scenario: Greeter
        Given a greeter
        When greeting the following persons:
          | Name  | Greeting   |
          | Joe   | Hello      |
          | Mary  | Hi, there! |
        Then the wold is a better place
        And the sun will shine                    #  <-- New step
...

```

The files can be regenerated with the same command:

    gherkin2robotframework example.feature

However, only the example.robot file will be generated (overwritten). The step definition will be parsed and
missing keywords will be generated to the console.

```
Processing gherkin: E:\GitHubProjects\gherkin2robotframework\examples\examples.feature

Missing keywords for: E:\GitHubProjects\gherkin2robotframework\examples\examples_step_definitions.robot

the sun will shine
    Fail    Keyword "the sun will shine" Not Implemented Yet

```

## Limitations and considerations

### Background support

The `Background` keyword is generated to implement the background part of the feature file. Each test case will
include this keyword. Using `[Test setup]` will not work for `Scenario Outline` with Examples.
In Cucumber the Background is applied to each example and in RobotFramework the `[Test setup]` is only applied to
the Test case and *NOT* to each line in the test case with `[Test Template]`.

### Language support

`#language:xx` is supported, but because the gherkin3 dependency is not recently updated on PyPI.
Therefore some keywords (and aliases) are not included.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "gherkin2robotframework",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "gherkin, robotframework",
    "author": null,
    "author_email": "Maurice Koster <maurice@mauricekoster.com>",
    "download_url": "https://files.pythonhosted.org/packages/17/db/be24bf6a77ae8de55113872827b0a32ef187ce41b141f98d0e661c138358/gherkin2robotframework-0.4.2.tar.gz",
    "platform": null,
    "description": "# gherkin2robotframework\n\n## Description\n\nThis tool can be used to facilitate the usage of Cucumber feature files in a RobotFramework Test Automation solution.\nAlthough RobotFramework supports BDD style test cases, this support is limited to Given/When/Then keywords.\nFeatures like datatables and docstrings are not supported in RobotFramework.\nThis tool will 'compile' Gherkin feature files into RobotFramework test cases and scaffolding for step definitions\naka User Keywords.\n\n## Usage\n\n### Example feature\n\n```gherkin\nFeature: Examples\n\n  As a tester\n  I want to specify feature files and translate it to RobotFramework\n  So I can use the best of both worlds\n\n  Background:\n    Given some background stuff\n\n  Scenario: Greeter\n    Given a greeter\n    When greeting the following persons:\n      | Name  | Greeting   |\n      | Joe   | Hello      |\n      | Mary  | Hi, there! |\n    Then the wold is a better place\n\n  @tag\n  Scenario Outline: Repetitive stuff\n    A nice description\n    on multiple lines\n    Given a thing with \"<thingy>\"\n    When some action\n    Then this happened: <stuff>\n\n    @A\n    Examples: A\n      Documentation for\n      example A\n      | thingy  | stuff |\n      | AAA     | 123   |\n      | BBB     | 456   |\n\n    @B\n    Examples: B\n      Documentation for example B\n      | thingy  | stuff |\n      | CCC     | 789   |\n      | DDD     | 000   |\n\n  @tag\n  Scenario Outline: More stuff\n    A nice description\n    on multiple lines\n    Given a thing with \"<thingy>\"\n    When doing action <action>\n    Then this happened: <stuff>\n\n    @A\n    Examples: A\n      Documentation for\n      example A\n      | thingy  | action | stuff |\n      | AAA     | take   | 123   |\n      | BBB     | give   | 456   |\n```\n\n### First time generation\n\nAfter creating your feature files you can translate these into RobotFramework test scripts with the following command:\n\n    gherkin2robotframework example.feature\n\nTwo files will be generated: *example.robot* containing the test cases and *example_step_definitions.robot* containing\nthe user keywords implement the steps. For the default english gherkins the Given/When/Then will be stripped\nfrom the keyword names.\n\n```robotframework: example.robot\n*** Settings ***\nDocumentation    As a tester\n...      I want to specify feature files and translate it to RobotFramework\n...      So I can use the best of both worlds\nResource    ./examples_step_definitions.robot\nMetadata    Feature    Examples\nMetadata    Generated by    _gherkin2robotframework on 2020-01-31T13:23:34.958405_\n\n*** Test Cases ***\nGreeter\n    Background\n    Given a greeter\n    ${DataTable}=    Create List\n    FOR    ${Name}    ${Greeting}    IN\n    ...    Joe    Hello\n    ...    Mary    Hi, there!\n        ${entry}=    Create Dictionary    Name=${Name}    Greeting=${Greeting}\n        Append To List    ${DataTable}    ${entry}\n    END\n    When greeting the following persons:    @{DataTable}\n    Then the wold is a better place\n\nRepetitive stuff: A\n    [Documentation]    Documentation for\n    ...    example A\n    [Tags]    tag    A\n    [Template]    Scenario Outline Repetitive stuff\n    AAA    123\n    BBB    456\n\nRepetitive stuff: B\n    [Documentation]    Documentation for example B\n    [Tags]    tag    B\n    [Template]    Scenario Outline Repetitive stuff\n    CCC    789\n    DDD    000\n\n\n*** Keywords ***\nBackground\n    Given some background stuff\n\nScenario Outline Repetitive stuff\n    [Documentation]    A nice description\n    ...    on multiple lines\n    [Arguments]    ${thingy}    ${stuff}\n    Background\n    Given a thing with \"${thingy}\"\n    When some action\n    Then this happened: ${stuff}\n\n```\n\n*example_step_definitions.robot*\n\n```robotframework\n*** Settings ***\nDocumentation    Generated by    _gherkin2robotframework on 2020-01-31T12:14:13.397524_\nLibrary    Collections\n\n*** Keywords ***\nsome background stuff\n    Fail    Keyword \"some background stuff\" Not Implemented Yet\n\na greeter\n    Fail    Keyword \"a greeter\" Not Implemented Yet\n\ngreeting the following persons:\n    [Arguments]    @{DataTable}\n    Fail    Keyword \"greeting the following persons:\" Not Implemented Yet\n\nthe wold is a better place\n    Fail    Keyword \"the wold is a better place\" Not Implemented Yet\n\na thing with \"${thingy}\"\n    Fail    Keyword \"a thing with \"${thingy}\"\" Not Implemented Yet\n\nsome action\n    Fail    Keyword \"some action\" Not Implemented Yet\n\nthis happened: ${stuff}\n    Fail    Keyword \"this happened: ${stuff}\" Not Implemented Yet\n\n```\n\n### Regeneration\n\nIn case your feature file is changed the .robot files needs to be regenerated.\n\n```gherkin\n...\n    Scenario: Greeter\n        Given a greeter\n        When greeting the following persons:\n          | Name  | Greeting   |\n          | Joe   | Hello      |\n          | Mary  | Hi, there! |\n        Then the wold is a better place\n        And the sun will shine                    #  <-- New step\n...\n\n```\n\nThe files can be regenerated with the same command:\n\n    gherkin2robotframework example.feature\n\nHowever, only the example.robot file will be generated (overwritten). The step definition will be parsed and\nmissing keywords will be generated to the console.\n\n```\nProcessing gherkin: E:\\GitHubProjects\\gherkin2robotframework\\examples\\examples.feature\n\nMissing keywords for: E:\\GitHubProjects\\gherkin2robotframework\\examples\\examples_step_definitions.robot\n\nthe sun will shine\n    Fail    Keyword \"the sun will shine\" Not Implemented Yet\n\n```\n\n## Limitations and considerations\n\n### Background support\n\nThe `Background` keyword is generated to implement the background part of the feature file. Each test case will\ninclude this keyword. Using `[Test setup]` will not work for `Scenario Outline` with Examples.\nIn Cucumber the Background is applied to each example and in RobotFramework the `[Test setup]` is only applied to\nthe Test case and *NOT* to each line in the test case with `[Test Template]`.\n\n### Language support\n\n`#language:xx` is supported, but because the gherkin3 dependency is not recently updated on PyPI.\nTherefore some keywords (and aliases) are not included.\n",
    "bugtrack_url": null,
    "license": "The MIT License (MIT)  Copyright (c) 2016 mauricekoster  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.  ",
    "summary": "Translate Gherkin feature files into RobotFramework tests",
    "version": "0.4.2",
    "project_urls": {
        "Repository": "https://github.com/mauricekoster/gherkin2robotframework.git"
    },
    "split_keywords": [
        "gherkin",
        " robotframework"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ce2c4d6ccf9fe295469ae0de5c5a741dcdc9ddd736d4e83da084f48953f1e482",
                "md5": "ebd2e44c2944dc4d77e2302a7557ab16",
                "sha256": "c227ffc67a9ad6659da4f14f0caedbf1d4a8b4f1af8eab3a472628c6c23654ba"
            },
            "downloads": -1,
            "filename": "gherkin2robotframework-0.4.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "ebd2e44c2944dc4d77e2302a7557ab16",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 11075,
            "upload_time": "2024-11-16T12:08:21",
            "upload_time_iso_8601": "2024-11-16T12:08:21.156761Z",
            "url": "https://files.pythonhosted.org/packages/ce/2c/4d6ccf9fe295469ae0de5c5a741dcdc9ddd736d4e83da084f48953f1e482/gherkin2robotframework-0.4.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "17dbbe24bf6a77ae8de55113872827b0a32ef187ce41b141f98d0e661c138358",
                "md5": "2e82d1bbb3654bdc95204d3f2f014f11",
                "sha256": "3369f2cc0c0b115b857b86ff0a00b49fbe65255a7e07d56ecda12bcb2c07735b"
            },
            "downloads": -1,
            "filename": "gherkin2robotframework-0.4.2.tar.gz",
            "has_sig": false,
            "md5_digest": "2e82d1bbb3654bdc95204d3f2f014f11",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 11656,
            "upload_time": "2024-11-16T12:08:22",
            "upload_time_iso_8601": "2024-11-16T12:08:22.901890Z",
            "url": "https://files.pythonhosted.org/packages/17/db/be24bf6a77ae8de55113872827b0a32ef187ce41b141f98d0e661c138358/gherkin2robotframework-0.4.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-16 12:08:22",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "mauricekoster",
    "github_project": "gherkin2robotframework",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "gherkin-official",
            "specs": [
                [
                    "==",
                    "29.0.0"
                ]
            ]
        },
        {
            "name": "wheel",
            "specs": [
                [
                    "==",
                    "0.44.0"
                ]
            ]
        }
    ],
    "lcname": "gherkin2robotframework"
}
        
Elapsed time: 1.05509s