找不到类型或命名空间名称 'Specflow_xxx_XUnitAssemblyFixture'(是否缺少 using 指令或程序集引用?)
The type or namespace name 'Specflow_xxx_XUnitAssemblyFixture' could not be found (are you missing a using directive or an assembly reference?)
在我的 specflow 演示 C# .NET Core 3.1 项目中安装此 nuget 包后,出现此错误:
Severity Code Description Project File Line Suppression State
Error CS0246 The type or namespace name
'Specflow_Demo_XUnitAssemblyFixture' could not be found (are you
missing a using directive or an assembly
reference?) Specflow.Demo ...\Specflow.Demo\Features\LoggedInDiscount.feature.cs\LoggedInDiscount.feature 3 Active
这是我的 csproj 文件:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.1.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
<PackageReference Include="SpecFlow.Tools.MsBuild.Generation" Version="3.9.22" />
<PackageReference Include="SpecFlow.xUnit" Version="3.9.22" />
<PackageReference Include="SpecRun.SpecFlow" Version="3.9.7" />
</ItemGroup>
</Project>
关闭Visual Studio中的所有文件并重建后,出现另一个错误:
我快速浏览了引用的 nuget 包中的类型。 None 个使用您那里的命名风格 'Specflow_Demo_XUnitAssemblyFixture' - none 个具有相似名称的类型。
因此,正如错误所说,该类型不存在。
SpecFlow 有一个与此相关的未解决问题:Type or namespace [TestNamespace]_XunitAssemblyFixture could not be found。你还能 运行 你的测试用例吗?上面的 link 表示它只是一个智能感知问题。
来自 comment 关于 GitHub 问题的讨论:
The generated assemblyFixture file (e.g.: [TestNamespace]_XunitAssemblyFixture) can be found in the obj folder (obj\Debug\targetframework\xUnit.AssemblyHooks.cs).
We realized that this is IntelliSense related "issue" (IntelliSense of VisualStudio itself, not R#).
As you all noticed, the build was successful, but the error was still there. This is because the generated code behind file (*.feature.cs) is opened in your editor. If you close them, and build again, the error will disappear.
...
BTW there is an ongoing PR which will move the generated files to the obj folder, so this problem will disappear when it'll be merged.
在我的 specflow 演示 C# .NET Core 3.1 项目中安装此 nuget 包后,出现此错误:
Severity Code Description Project File Line Suppression State Error CS0246 The type or namespace name 'Specflow_Demo_XUnitAssemblyFixture' could not be found (are you missing a using directive or an assembly reference?) Specflow.Demo ...\Specflow.Demo\Features\LoggedInDiscount.feature.cs\LoggedInDiscount.feature 3 Active
这是我的 csproj 文件:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.1.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
<PackageReference Include="SpecFlow.Tools.MsBuild.Generation" Version="3.9.22" />
<PackageReference Include="SpecFlow.xUnit" Version="3.9.22" />
<PackageReference Include="SpecRun.SpecFlow" Version="3.9.7" />
</ItemGroup>
</Project>
关闭Visual Studio中的所有文件并重建后,出现另一个错误:
我快速浏览了引用的 nuget 包中的类型。 None 个使用您那里的命名风格 'Specflow_Demo_XUnitAssemblyFixture' - none 个具有相似名称的类型。
因此,正如错误所说,该类型不存在。
SpecFlow 有一个与此相关的未解决问题:Type or namespace [TestNamespace]_XunitAssemblyFixture could not be found。你还能 运行 你的测试用例吗?上面的 link 表示它只是一个智能感知问题。
来自 comment 关于 GitHub 问题的讨论:
The generated assemblyFixture file (e.g.: [TestNamespace]_XunitAssemblyFixture) can be found in the obj folder (obj\Debug\targetframework\xUnit.AssemblyHooks.cs). We realized that this is IntelliSense related "issue" (IntelliSense of VisualStudio itself, not R#). As you all noticed, the build was successful, but the error was still there. This is because the generated code behind file (*.feature.cs) is opened in your editor. If you close them, and build again, the error will disappear.
...
BTW there is an ongoing PR which will move the generated files to the obj folder, so this problem will disappear when it'll be merged.