Forum Discussion

Sabiha's avatar
Sabiha
Occasional Contributor
2 years ago

Using tags with examples/scenario outlines

Hi,

I have several BDD scenarios where I need to use scenario outlines and tags. I am programmatically running the tests and I am passing in the tags that I want to match against.

 

The format of the BDD is as follows:

 

test1 @Smoke @All @Card

Scenario: Test 1

 Given...

 When ...

 Then ...

 

@System1

Examples:

 |Value|

 | a      |

 

@System2 @System3

Examples:

|Value|

|b|

 

For example, I may want to run this scenario if I am running @smoke tests  and sometimes I may want to use the data from examples table @System1, but at other times I may want to use the exampels table for@System2/@System3

 

In my script I am checking for the existence of both @Smoke and @System1 tags, however it does not seem to be detecting the @System1 tag

 

I have tried moving the tags around, but I either get both sets of examples run or neither.  

 

Can this be done? If so, where should I put the tags for them to be picked up? Currently it looks as though it is only detecting the tags specified for the scenario not those for the examples tables

 

7 Replies

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    Here's an example, I'm using Tag Expression in Execution Plan to run tags two and three or four

     

    • Sabiha's avatar
      Sabiha
      Occasional Contributor

      HI, Yes I've checked through all the TestComplete documentation regarding Tags.

       

      The examples shown in the documentation only have Tags on the Examples table. In my example, I have tags for the scenario and the examples table and I want to match tags from both. 

  • Sabiha's avatar
    Sabiha
    Occasional Contributor

    Is there a way of doing this using scripts? We don't use the Execution plan, everything runs via scripts.

     

    • Sabiha's avatar
      Sabiha
      Occasional Contributor

      I am essentially using what is described in option 2, but it doesn't seem to picking up the tags for  the examples tables

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    Here's an example,

    Where I'm running Examples @four.

     

    To run Example @three, change the following lines to

        var example = scenario.Examples.Item(0);
        if (example.Tags.Contains("@three")) {
            example.Run();
        }