XUnit 'Startup' 不存在
XUnit 'Startup' does not exist
在我的 xunit 项目中出现以下错误
The type or namespace name 'Startup' does not exist in the namespace 'TestService' (are you missing an assembly reference?) [Testervice.Tests]
我使用
添加了对 Testervice.Tests 的 TestService 引用
dotnet add reference ..\TestService\TestService.csproj
引用已成功添加到测试项目中,并且在 TestService.csproj 文件中也可用。但我仍然收到错误。为什么我得到 error.Any 一试帮助我。
我不确定这是否能解决您的问题,但您需要创建一个继承原始 Startup.cs 的 TestStartUp class 以正确构建您的 .net 核心应用程序。示例代码如下所示。
public class TestStartup : Startup
{
public TestStartup(IConfiguration configuration, IHostingEnvironment hostingEnvironment) : base(configuration, hostingEnvironment)
{
}
}
希望这能解决您的问题。
在我的 xunit 项目中出现以下错误
The type or namespace name 'Startup' does not exist in the namespace 'TestService' (are you missing an assembly reference?) [Testervice.Tests]
我使用
添加了对 Testervice.Tests 的 TestService 引用dotnet add reference ..\TestService\TestService.csproj
引用已成功添加到测试项目中,并且在 TestService.csproj 文件中也可用。但我仍然收到错误。为什么我得到 error.Any 一试帮助我。
我不确定这是否能解决您的问题,但您需要创建一个继承原始 Startup.cs 的 TestStartUp class 以正确构建您的 .net 核心应用程序。示例代码如下所示。
public class TestStartup : Startup
{
public TestStartup(IConfiguration configuration, IHostingEnvironment hostingEnvironment) : base(configuration, hostingEnvironment)
{
}
}
希望这能解决您的问题。