I've only started to work with specflow and i know it's bindings are global for the assembly. Anyways, i couldn't find the solution or workaround for my problem:
I use abstract class for my UI tests, such as
public abstract class UITestBase<T> where T : FeatureContext, new() { private static readonly object SyncObject = new object(); private static AutoTestSettings settings; private IWebDriver webDriver; private IBrowserFactory browserFactory; private Container container; protected static T Context; [BeforeScenario] public virtual void BeforeScenario() { BuildConfiguration(); var driverPool = container.GetInstance<IWebDriverPool>(); webDriver = driverPool.GetDriver(settings.BrowserType); browserFactory = container.GetInstance<IBrowserFactory>(); Context = new T { Browser = browserFactory.Create(webDriver, settings.WebsiteUrl, settings.BrowserType), Container = container }; } [AfterScenario] public virtual void AfterScenario() { webDriver.Dispose(); } }
I have few FeatureSteps files, one for each page/feature. E.g LoginFeature and PurchaseFeature. Each FeatureSteps class extends UITestBase and has [Binding] attribute.
Whenever I run scenario for
LoginFeature
it seems to hook onBeforeScenario
forPurchaseFeatureSteps
as well. At least thats whatDebug.WriteLine(this.GetType().Name)
says.It causes that each scenario opens as many browsers as there are inheritors of
UITestBase
. Although tests are running fine it looks sorta ugly and feels wrong.Did anyone face such problem? How do I fix it?