You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Classic project format using <PackageReference> tags
Sdk-style project format
.feature.cs files are generated using
SpecFlow.Tools.MsBuild.Generation NuGet package
SpecFlowSingleFileGenerator custom tool
Visual Studio Version
VS 2019
VS 2017
VS 2015
Enable SpecFlowSingleFileGenerator Custom Tool option in Visual Studio extension settings
Enabled
Disabled
Are the latest Visual Studio updates installed?
Yes
No
.NET Framework:
>= .NET 4.5
before .NET 4.5
.NET Core 2.0
.NET Core 2.1
.NET Core 2.2
.NET Core 3.0
Test Execution Method:
Visual Studio Test Explorer
TFS/VSTS/Azure DevOps – Task – PLEASE SPECIFY THE NAME OF THE TASK
Command line – PLEASE SPECIFY THE FULL COMMAND LINE
<SpecFlow> Section in app.config or content of specflow.json
No config file in use.
Issue Description
If you set the <RootNamespace> element of an SDK-style project to be empty, SpecFlow complains. In V2, it used to fall back to a default namespace, and the code to do that is still in there, but the Feature File Codebehind MSBuild Task marks the property by which it discovers the default namespace as [Required] meaning that if you're using this new codebehind generation approach, you can no longer have an empty root namespace
Steps to Reproduce
Create a simple test project that uses SpecFlow. (Any test runner.)
Edit the .csproj so that it has <RootNamespace></RootNamespace> in it (or set the default namespace to be empty in the project settings UI.
Add a SpecFlow feature file.
Build
You will get an error complaining that the root namespace is required.
This happens because MSBuild does not distinguish between empty strings and null. Setting the root namespace to an empty string effectively tells it that there is no value for that setting, causing the execution of the SpecFlow feature codebehind generator task to fail.
More information
Some companies like to have a file folder structure that directly reflects the namespace hierarchy. In cases where you need to put things in external namespaces (as is a common convention for certain extension methods) there is no common root namespace, so you need the folder structure to reflect the entire namespace, at which point you need to set <RootNamespace> to be empty, otherwise VS will put the wrong namespaces on new files that you add.
The text was updated successfully, but these errors were encountered:
SpecFlow Version:
Used Test Runner
Version number: 3.0.213
Project Format of the SpecFlow project
packages.config
<PackageReference>
tags.feature.cs files are generated using
SpecFlow.Tools.MsBuild.Generation
NuGet packageSpecFlowSingleFileGenerator
custom toolVisual Studio Version
Enable SpecFlowSingleFileGenerator Custom Tool
option in Visual Studio extension settingsAre the latest Visual Studio updates installed?
.NET Framework:
Test Execution Method:
<SpecFlow> Section in app.config or content of specflow.json
No config file in use.
Issue Description
If you set the
<RootNamespace>
element of an SDK-style project to be empty, SpecFlow complains. In V2, it used to fall back to a default namespace, and the code to do that is still in there, but the Feature File Codebehind MSBuild Task marks the property by which it discovers the default namespace as[Required]
meaning that if you're using this new codebehind generation approach, you can no longer have an empty root namespaceSteps to Reproduce
.csproj
so that it has<RootNamespace></RootNamespace>
in it (or set the default namespace to be empty in the project settings UI.You will get an error complaining that the root namespace is required.
This happens because MSBuild does not distinguish between empty strings and null. Setting the root namespace to an empty string effectively tells it that there is no value for that setting, causing the execution of the SpecFlow feature codebehind generator task to fail.
More information
Some companies like to have a file folder structure that directly reflects the namespace hierarchy. In cases where you need to put things in external namespaces (as is a common convention for certain extension methods) there is no common root namespace, so you need the folder structure to reflect the entire namespace, at which point you need to set
<RootNamespace>
to be empty, otherwise VS will put the wrong namespaces on new files that you add.The text was updated successfully, but these errors were encountered: