Running a Frank cucumber scenario multiple times

313 views Asked by At

I have 3 Frank/Cucumber scenarios, all related to logging in, on different environments: demo, preproduction, production.

I also have a separate Frank/Cucumber scenario that does the log out (which is always the same if the previous scenarios were successful).

What would I have to do to call this logout scenario after each login scenario instead of sequentially? I.e. How can I call the logout scenario multiple times?

Thank you.

2

There are 2 answers

0
basti1302 On

Did you have a look at hooks? From what you have said, the log out step could be a hook rather than a scenario of its own. Like this:

support/hooks.rb:

After do |scenario|
  if(!scenario.failed?)
     ... logout of app ...
  end
end

Of course, if you also want to test your log out functionality then you should have a feature that specifically tests the log out. But if you just want to make sure that the user is being logged out after your login feature has run, then hooks are the way to go, IMHO.

Edit: If you do not log in in all of your scenarios, you might also not want to log out after each scenario. That's what tagged hooks are for.

0
Sulthan On

In my "Log in" / "Log out" tests, I usually have one big scenario where I test the feature step by step and then another bigger step where I do the same functionality, so I can use it easily several times.

However, if you are running the same tests, only on different environments, maybe you should just run cucumber again with different enviroment variables?