SpecFlowOSS / SpecFlow

#1 .NET BDD Framework. SpecFlow automates your testing & works with your existing code. Find Bugs before they happen. Behavior Driven Development helps developers, testers, and business representatives to get a better understanding of their collaboration
https://www.specflow.org/
Other
2.24k stars 754 forks source link

C# Specflow 3: BeforeScenario is not called when multiple projects in same solutions #1842

Open SandeepDhamale19 opened 4 years ago

SandeepDhamale19 commented 4 years ago

SpecFlow Version:

Used Test Runner

Version number:

Project Format of the SpecFlow project

.feature.cs files are generated using

Visual Studio Version

Enable SpecFlowSingleFileGenerator Custom Tool option in Visual Studio extension settings

Are the latest Visual Studio updates installed?

.NET Framework:

Test Execution Method:

<SpecFlow> Section in app.config or content of specflow.json

{
    "bindingCulture":
    {
        "language" :"en-us"
    },
    "language":
    {
        "feature": "en-us"
    }
}

Repro Project

Issue Description

  1. I've 2 projects in my solution. One is a framework project having helper files and another with Specflow scenarios.
  2. When trying to execute scenarios, hooks are ignored e.g. 'BeforeScenario'. This does not initialize the driver and other parameters.

Step Definition File { [Binding] public class SignInSteps : UIFramework { private readonly ScenarioContext context;

    static IWebDriver wbedriver;
    public SignInSteps(ScenarioContext injectedContext)
    {
        context = injectedContext;
        UIController.Instance.Driver = wbedriver;
    }

    [Given(@"user is Navigated to URL")]
    public void GivenUserIsNavigatedToURL()
    {
        UIActions.NavigateToUrl();
    }

}

}

Hooks File: { [Binding] [TestClass] public class Hooks { private IWebDriver driver; private readonly IObjectContainer _objectContainer;

   public Hooks(IObjectContainer objectContainer)
    {
        this._objectContainer = objectContainer;
    }

  [BeforeScenario("Chrome")]
    public void InitializeChromeDriver()
    {
        ConfigureChromeSetup();
        _objectContainer.RegisterInstanceAs(driver);
    }

 [AfterScenario]
  public void AfterScenario()
    {
            var driver = _objectContainer.Resolve<IWebDriver>();
            driver.Quit();     }
    }

Steps to Reproduce

SabotageAndi commented 3 years ago

Do you have still this issue?