ReuseAutomator
ReuseAutomator

Reputation: 420

Specflow-Run Steps Multiple times - Only When step

I have a scenario like logging in & running a test like add user multiple times with different data. The data drive we achieved by using excel. But the issue is the login happens for each scenario. How to avoid login for each scenario and run login only once but the when part which is add user multiple times in same session?

Upvotes: 1

Views: 954

Answers (1)

Sam Holder
Sam Holder

Reputation: 32936

if you don't want to login for each scenario then you can do it once for the feature by adding a BeforeFeature hook. something like this:

[Binding]
public class Hooks
{
    [BeforeFeature]
    public static void BeforeFeature()
    {
        \\...add login logic...
    }
}

There are other hooks as well, in case you want to do it before the entire test run.

Upvotes: 1

Related Questions