Search code examples
rubyselenium-webdrivercucumbercapybarasite-prism

Background step sometimes never executes before few scenarios on a cucumber feature file


I saw a wired issue recently that Background step sometimes don't executes before few scenarios in a feature file. I have no idea why this is happened. Any body saw this issue in cucumber ruby framework? Is there any limitations of scenario count on each feature file? In below examples, i saw Background step executes only for 1st 5 scenarios but not others.

Feature: Something

Background: Given step 1 And step 2

Scenario: a scenario When I do step 3 Then it works

Scenario: another scenario When I do a different step 3 Then it works

Scenario: another scenario 4 When I do a different step 4 Then it works

Scenario: another scenario 5 When I do a different step 5 Then it works


Solution

  • If this is actually the case, then it would be a bug in cucumber and should be reported over at the cucumber project. It's more likely that it is actually executing the background but you have requests still running at the end of previous tests that are modifying your database and making it look like the background isn't running. You can test that by adding a step into the background that outputs something to the screen and then count how many times is is output.