4
votes

While running scenarios of two different feature files I am getting following error: Initialization method ITTCustomerScenarios.Features.ValidateTheJAMCMSKULicensingFeature.TestInitialize threw exception. TechTalk.SpecFlow.SpecFlowException: TechTalk.SpecFlow.SpecFlowException: The FeatureContext.Current static accessor cannot be used in multi-threaded execution. Try injecting the feature context to the binding class. See http://go.specflow.org/doc-multithreaded for details..

Though I am able to run scenarios of different features files from visual studio but not from mstest. The command I am using for running sceanrios from command line using mstest is: mstest /testcontainer:"test.dll" /category:mytest

test1.feature @mytest Scenario: Verify login Given I visit home page ..... ......

test2.feature @mytest Scenario: Verify logout Given I visit home page ..... ......

Please suggest me how to run scenarios of different feature files from command line.

4

4 Answers

1
votes

Found a link here which may be useful to some.
TLDR: "The solution here is to explicitly regenerate all feature files."

0
votes

Update your specflow version and generator version to following one SpecFlow Version:2.1.0.0(or latest) SpecFlow Generator Version:2.0.0.0(or latest)

Regenerate all feature.cs files explicitly.

This will work for you. :)

0
votes

I've solved the same problem by injecting the context in constructor like below. I guess this problem became after an update. Because ScenarioContext.Current is obsolete now.

    private readonly ScenarioContext Context;

    public WikipediaTitleValidationSteps(ScenarioContext catalogContext)
    {
        Context = catalogContext;
    }
-2
votes

If you follow the link in the error message, you have a description how to solve it.