Coder Social home page Coder Social logo

Comments (4)

davidvesely avatar davidvesely commented on August 11, 2024 1

Same problem here, we can't use Autofac and run tests in parallel when the FeatureContext or ScenarioContext is injected in the constructors. We need either to stop using Autofac, or remove the FeatureContext dependencies.
@finaruioana did you found any solution to the problem yet?

from specflow.autofac.

wekempf avatar wekempf commented on August 11, 2024

I really wish this plugin handled this stuff for you. The plugin should include an extension method so you could do something as simple as:

builder.RegisterSpecFlowTypes();

For ScenarioContext, the following is working for me in limited testing.

builder.Register(_ => ScenarioContext.Current).InstancePerDependency().ExternallyOwned();

There's likely still a race condition here, but this is the best I could do without really digging deep into both the source of this plugin and SpecFlow itself. :(

This plugin severely needs support for context injection. As is, it entirely replaces BoDi and thus breaks existing conventions.

from specflow.autofac.

ParagRaut avatar ParagRaut commented on August 11, 2024

Oh God I'm waiting since so long for this plugin to support context injection with AutoFac
@gasparnagy Is there any way you can make it possible in Specflow.AutoFac plugin to inject FeatureContext and ScenarioContext ?

from specflow.autofac.

ParagRaut avatar ParagRaut commented on August 11, 2024

Hi,

I am trying to enable running tests in parallel, but I cannot seem to make it work.

I had an AfterScenario hook which initially was verifying the static ScenarioContext.Current.TestError value.
All the DI registration is made using Specflow.Autofac package.

After upgrading NUnit to version 3.6.1, it threw an exception complaining about the use of this static ScenarioContext with a link to http://specflow.org/documentation/Parallel-Execution/

I made the update in my step class as in above link:
`
[Binding]
public class StepsWithScenarioContext
{
private readonly ScenarioContext scenarioContext;

public StepsWithScenarioContext(ScenarioContext scenarioContext)
{
    if (scenarioContext == null) throw new ArgumentNullException("scenarioContext");
    this.scenarioContext = scenarioContext;
}

[AfterScenario]
public void AfterScenario()
{
     if (_scenarioContext.TestError != null)  
            //do something
}

}
`

But now, the below exception is thrown:
Cannot resolve parameter 'TechTalk.SpecFlow.ScenarioContext scenarioContext'

I tried to find a way to register this scenario context into my DI, but wasn't able to find a way.
Did anyone else had this issue?
Is there a way to register the ScenarioContext into Specflow.Autofac registration?

Thank you and happy coding!

@finaruioana @davidvesely @wekempf Still no resolution,

Have you tried asking this question in new specflow respository issue tracking ?

from specflow.autofac.

Related Issues (16)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.