4

Using Cucumber with Javascript and Selenium I have the following Gherking file:

    Feature: Login

    Background:
        Given database is filled with these emails and passwords.
        | tobias@hotmail.com | 12345678 |
        | petecle@gmail.com  | 87654321 |

    Scenario Outline:
        Given I navigate to the landing page
        When I submit the login form with "<email>" and "<password>"
        Then I can see the welcome message

    Examples:
        | email              | password |
        | tobias@hotmail.com | 12345678 |
        | petecle@gmail.com  | 87654321 |

My issue is that the background runs twice. Is there a way I can run it only once?

5
  • Background runs per scenario, and as you are using a scenario outline with two data combinations, there will be two scenarios. And thus it will get executed two times. I don't think there is a way to stop this, but i think you can achie beforesuite using testng + cucmber – PDHide Mar 22 '20 at 21:09
  • medium.com/agile-vision/… – PDHide Mar 22 '20 at 21:17
  • This is a nice article, you could use the @beforClass to fill database with details you want before running the featur – PDHide Mar 22 '20 at 21:17
  • Why do you need to run it only once? Is there a problem that you are encountering? – Greg Burghardt Apr 23 '20 at 12:43
  • Why do you want to run the same scenario with two emails? There's no evidence of some difference between those users. At least, it's not expressed in the feature. – roman May 3 at 15:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.