Skip to content

Instantly share code, notes, and snippets.

@Tset-Noitamotua
Last active May 13, 2024 11:06
Show Gist options
  • Save Tset-Noitamotua/8f06bd490918a56b0485630016aef60b to your computer and use it in GitHub Desktop.
Save Tset-Noitamotua/8f06bd490918a56b0485630016aef60b to your computer and use it in GitHub Desktop.
HOW TO translate Cucumber test case into Robot Framework (RF) test case

Cucumber test with examples table

Scenario Outline: eating cucumbers
  Given there are <start> cucumbers
  When I eat <eat> cucumbers
  Then I should have <left> cucumbers

  Examples:
    | start | eat | left |
    |  12   |  5  |  7   |
    |  20   |  5  |  15  |

RobotFramework test with template keyword

*** Test Cases ***
Scenario: eating cucumbers
    [Template]  Scenario Outline: eating cucumbers

    # Examples:
    # start  eat  left
    12       5    7
    20       5    15
    33       11   22
    35       15   20


*** Keywords ***
Scenario Outline: eating cucumbers
    [Arguments]  ${start}  ${eat}  ${left}
    Given there are ${start} cucumbers
    When I eat ${eat} cucumbers
    Then I should have ${left} cucumbers


# steps implementation
there are ${x} cucumbers
    Set Test Variable  ${start}  ${x}
    log    ${start}

I eat ${y} cucumbers
    Set Test Variable  ${eat}  ${y}
    log    ${start}
    log    ${eat}
    
I should have ${z} cucumbers
    Set Test Variable  ${left}  ${z}
    log   ${start}
    log   ${eat}
    log   ${left}

    ${result}=  Evaluate  ${start} - ${eat}
    Should be equal as strings  ${result}  ${left}
@SeleniumGithu
Copy link

Hi, could you please provide detailed steps, such as which Library needs to be install/Add, How do we attache feature file to the FW? How to run Test Cases...etc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment