Search code examples
javacucumbertaggingscenariossmoke-testing

Cucumber: @SmokeTest Tagging one scenario out of a scenario outline


I am new to tagging in Cucumber. I have built up an automation suite and have identified all tests which can be effectively tagged as Smoke Tests using the @SmokeTest tag.

However is there a way to do the following? I don't want to tag the whole of the Scenario Outline as a SmokeTest - but just want one test/response to be the Scenario as per below:

What I don't want - as this will test all scenarios

@SmokeTest    
Scenario Outline: Number is or is not valid
    Given I send an event with the "Number" set to <num>
    Then I will receive the following <message>
    Examples:
        | num    | message           |                                                                                     
        | 0      | "Processed event" |                                                        
        | 1      | "Processed event" |                                                                  
        | 2      | "Processed event" |                                                                 
        | 3      | "Processed event" |                                                                 
        | 4      | "Processed event" |                                                                 
        | 5      | "Processed event" |                                                                                                                                 
        | 6      | "Message failed"  |
        | -1     | "Message failed"  |
        | "One"  | "Message failed"  |

What I would like to have - using the Number of 1 as tagged as my Smoke Test

Scenario Outline: Number is or is not valid
    Given I send an event with the "Number" set to <num>
    Then I will receive the following <message>
    Examples:
           | num    | message           |                                                                                     
           | 0      | "Processed event" |                                                        
@SmokeTest | 1      | "Processed event" |                                                                  
           | 2      | "Processed event" |                                                                 
           | 3      | "Processed event" |                                                                 
           | 4      | "Processed event" |                                                                 
           | 5      | "Processed event" |                                                                                                                                 
           | 6      | "Message failed"  |
           | -1     | "Message failed"  |
           | "One"  | "Message failed"  |

Is this possible? Or would it be better to create a separate scenario definition with the Smoke Test I just want?

Many thanks!

Kirsty


Solution

  • You can tag examples sections and have multiple examples sections.

    @SmokeTest    
    Scenario Outline: Number is or is not valid
        Given I send an event with the "Number" set to <num>
        Then I will receive the following <message>
      
        @SmokeTest
        Examples: 
            | num    | message           |                                                                                     
            | 0      | "Processed event" |   
    
        Examples: You can also name these 
            | num    | message           |                                                                                                                                          
            | 1      | "Processed event" |                                                                  
            | 2      | "Processed event" |