asp.net-core - XUnit '启动' 不存在
问题描述
在我的 xunit 项目中,我收到以下错误
命名空间“TestService”中不存在类型或命名空间名称“Startup”(您是否缺少程序集引用?)[Testervice.Tests]
我通过使用将 TestService 引用添加到 Testervice.Tests
dotnet add reference ..\TestService\TestService.csproj
该引用已成功添加到测试项目中,并且在 TestService.csproj 文件中也可用。但我仍然收到错误消息。为什么我收到错误消息。任何人尝试帮助我。
解决方案
我不确定这会解决您的问题,但您需要创建一个继承原始 Startup.cs 的 TestStartUp 类来正确构建您的 .net 核心应用程序。示例代码如下所示。
public class TestStartup : Startup
{
public TestStartup(IConfiguration configuration, IHostingEnvironment hostingEnvironment) : base(configuration, hostingEnvironment)
{
}
}
希望这能解决您的问题。
推荐阅读
- javascript - 创建一个新的多字符脚本。但得到错误无法设置属性'innerhtml'为空
- oracle - oracle 中的有序提示是否也决定了获取它们的行的顺序?
- swiftui - 在 TextField 更改后 NavigationLink 关闭
- pdf - 使用 Ghostscript 通过 pdfmarks 设置 PDF 自然语言
- django - CKEditor在 Django 中删除
- python - 刮表,其中行分布在许多 tr 之间
- r - 按组将 data.frame 拆分为向量列表而不是 data.frames 列表
- javascript - 如何从discord.js中的文件夹中随机选择一张图片
- python - 为什么我没有输出?而不是下面代码中的图像
- json - 如何使用 Scala 从 JSON 文件中读取字符串列表