Search code examples
protractorbddwebdriver-iocucumberjs

Execute single cucumber test case in a scenario outline using command line command


I want to execute single test case from a scenario outline using protractor.For example in the below Scenario Outline if I want to execute the test case TCID0002 alone, how I can run the test case TCID0002 using protractor?

@shopping
Scenario Outline: Test
    Given the user navigates to xxx.com
    When the user searches for <product>
    Then the current page is shopping cart page
    Examples:
    |TCID    |  product|
    |TCID0001|soap     |
    |TCID0002|watch    |
    |TCID0003|lipstick |

To run all the test case now I use

protractor Config.js --cucumberOpts.tags="@shopping" 

Is there any command to execute single test case in the scenario outline ?


Solution

  • Found solution to execute single test case in cucumber with a help of my team member.

    To run single test case follow the below 2 steps

    Step 1

    Keep TCID in the scenario title as shown below

    Scenario Outline: <TCID> test case to validate search
        Given the user navigates to xxx.com
        When the user searches for <product>
        Then the current page is search result page
        Examples:
        |TCID    |  product|
        |TCID0001|soap     |
        |TCID0002|watch    |
        |TCID0003|lipstick |
    

    Step 2

    Use cucumberOpts.name in your command. 'cucumberOpts.name' will filter the scenarios which contain the given string in the scenario title. --cucumberOpts.name="WAGCAR0002" will filter the WAGCAR0002 scenario alone.

    Command

    The below command will execute the test case 'WAGCAR0002'

    protractor Config/wagConfig.js --cucumberOpts.name="WAGCAR0002"