Does if else concept available in feature file (Gherkin language)?

后端 未结 4 1075
暖寄归人
暖寄归人 2021-01-18 21:32

Is there anyway where we can use if/else concept in feature file? For example:

  Scenario: User should be able to check login page
  Given I am on login pag         


        
4条回答
  •  独厮守ぢ
    2021-01-18 22:17

    No you can't and you shouldn't. Feature files are for business behaviour, not programming.

    From your scenario I think you are trying to deal with different behaviour, depending on whether you are registered or not. To do this you would write two scenarios

    Given I am registered
    When I 
    Then I should ....
    
    Given I am a new user
    When I ...
    Then I should be asked to register
    

    Notice how these scenarios don't describe 'how' anything is done. Anything like `I click on foo' in feature is a smell and should be avoided.

提交回复
热议问题