Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unrecognized element unitTestProvider

I am new to the SpecFlow and i setup installation with SpecFlow package and the base contribution of SpecFlow addition packages ( which comes with NUnit).

After adding my feature files then I got some problem with a custom tool to generate SpecFlowsingleFilegenerations ( and I fixed those by removing an option from properties)

Then when I rebuild the solution. It shows some Unrecognized element in appconfig file for the unittestprovider

error :[SpecFlow] System.Configuration.ConfigurationErrorsException: Unrecognized element 'unitTestProvider'.

My appconfig file specflow section

<specFlow>
    <unitTestProvider name="NUnit" />
    <plugins>
      <add name="Baseclass.Contrib.SpecFlow.Selenium.NUnit" path="..\packages\Baseclass.Contrib.SpecFlow.Selenium.NUnit.1.3.1\tools" /> 
    </plugins>

  </specFlow>
like image 907
PavanS Avatar asked May 12 '19 04:05

PavanS


1 Answers

That config file will not work with version 3.0 and up of SpecFlow. You can read the documentation on how to update to 3.0 here. It says:

Changes to How Unit Test Providers are Configured

In previous versions of SpecFlow, the unit test provider used to execute tests was configured in your app.config file. As of SpecFlow 3, we strongly recommend configuring your unit test provider by installing one of the available packages (see below).

And also:

specflow.json

Moving forward, we recommend using specflow.json to configure SpecFlow, rather than app.config. .NET Core projects require specflow.json (app.config is not supported). While using specflow.json is optional for Full Framework projects, we recommend migrating to the new format. For more details, see Configuration in the documentation.

So you can remove SpecFlow from app.config and create a file called specflow.json instead. You can put the following into it:

{
    "language": {
        "feature": "en-US"
    }
}

You can change language to something else if you want to.

You have to add a test runner to your project, if you don't have that already. In your case, it's NUnit, so add SpecFlow.NUnit with NuGet. You generally need the packages that are listed in the example project for NUnit.

like image 118
Mika Sundland Avatar answered Oct 28 '22 17:10

Mika Sundland