To make it easier to create new SpecFlow projects, we have created a project template that you can access with
dotnet new. As with all templates, you need to install them first before you can use the templates. More information on installing templates can be found here.
Note: You need the .NET Core SDK installed to use templates.
To install the template, execute the following command from the command line of your choice:
dotnet new -i SpecFlow.Templates.DotNet
Once the installation is complete, you can create new project with the following command:
dotnet new specflowproject
This creates a .NET Core 3 project with the same name as the current folder. SpecFlow+Runner is configued as default test runner. You can define a different test runner or target framework using the following optional parameters.
- framework: the following values are supported:
- netcoreapp3.0 (default): .NET Core 3
- netcoreapp2.2 : .NET Core 2.2
- net472: .NET 4.7.2
- unittestprovider: can be one of the following:
- specflowplusrunner (default): SpecFlow+ Runner
- xunit: XUnit
- nunit: NUnit
- mstest: MSTest
dotnet new specflowproject --unittestprovider xunit --framework netcoreapp2.2
This creates a new project with XUnit as the unit test provider, and targetting .NET Core 2.2. The project is created with a pre-defined structure that follows best practices. The project includes a single feature file (in the Features folder) and its associated steps (in the Steps folder).
In addition to the project template, we added also some item templates to the template pack, which includes the following:
- specflow-feature: .feature file in English
- specflow-json: specflow.json configuration file
- specflow-plus-profile: Default.srProfile (SpecFlow+Runner configuration)
If you have additional ideas for the templates, please open a GitHub issue here.
Big thanks go out to our intern Manuel for creating these templates!