Mary Dear
Mary Dear

Reputation: 185

Can I use Examples in Background block?

I need background to be run with 2 different roles. I'm not allowed to do this:

 Background:
    Given I login as existing user with role "<role>"
    And I choose to create new Account

    Examples: 
        | role          |   
        | Standard User |
        | Site Admin    |

What is the best way to resolve this issue?

Upvotes: 0

Views: 421

Answers (2)

diabolist
diabolist

Reputation: 4109

You have two separate pieces of behaviour here so do a scenario, or even a feature for each one.

In most applications different rules will apply for users and admins, and in many systems and even different ui's will be used.

A top rule for scenario writing is that its much better to have lots of simple scenarios than a few complex ones.

Upvotes: 1

Ranjith&#39;s
Ranjith&#39;s

Reputation: 4740

It's not possible with Background.. you can use Scenario Outline in feature:

For example:

Scenario Outline:

 Given I login as existing user with role "<role>"
 And I choose to create new Account

    Examples: 
        | role          |   
        | Standard User |
        | Site Admin    |

Upvotes: 1

Related Questions