VS 2017 中的创建单元测试在哪里?
Where is Create Unit Test in VS 2017?
我知道这个问题之前已经在 SO 上被问过,而且这个功能似乎在某个时候从 VS 中删除了。但是我现在正在查看 Microsoft tutorial,它说 VS 2017 中应该有一个创建单元测试功能。
我正在尝试测试 ASP.NET 核心 MVC 控制器。我已按照创建测试项目的步骤进行操作。但是当我右键单击 namespace/class/method.
时,我仍然看不到任何这样的选项
编辑:我正在使用 Visual Studio 2017 社区版
以下答案仅与 .NET Core/Standard 相关。如果您缺少完整 .NET Framework 项目的“创建单元测试”选项 。
当前状态:现在可用于 .NET Core!
我现在在 Visual Studio Professional 2019 版本 16.3.0 预览版 3.0 上的 Core 3 解决方案 运行 中有创建单元测试上下文菜单。不确定它何时重新出现,因为我一直在定期更新每个新的预览版本。
历史
有关更多历史记录和详细信息,请参阅下面的更新。
原始答案 2017 年 6 月
来自 Microsoft's Jayarani Garg 的 GitHub 条目确认它仅适用于针对完整 .NET 框架的项目:
Jayarani Garg [MSFT] · Feb 27 2017 at 06:09 AM Hi,
Thank you for your feedback. "Create Unit Test" is currently not
supported for .Net Core projects.
根据同一 Visual Studio 开发者社区页面上的 this Visual Studio Team comment,这是设计使然,而不是错误:
Visual Studio Team ♦♦ · Mar 10 2017 at 01:06 PM
Thank you for your feedback! The Visual Studio team has determined that this issue
is not a bug. However, we will consider this feedback and have created
https://github.com/Microsoft/vstest/issues/592 to track this. Please
feel free to vote for the issue.
上面提到的 Microsoft VS 测试存储库 Create Unit Test Context Menu Missing (.net core projects) is slightly confusing. It's asking for this feature to be added for .NET Core projects too but then a Microsoft employees talk about having a fix for an issue. I believe that employee is referring to the old bug where the context menu option wasn't working for full .NET framework projects either 中提到的 github 问题,该线程中也提到了该问题。据我所知,该线程并不是说他们已经为 .NET Core 项目添加了菜单选项。
我也刚刚查看了 Visual Studio Professional 2017 版本 15.2 (26430.6) 的副本,我 do 有一个项目的创建单元测试选项以完整的 .NET 框架为目标(这个以 .NET Framework 4.5.1 为目标):
但是我没有针对 .NETCoreApp 1.1 的项目:
2018 年 6 月更新
Microsoft 已注意到 feature request 的投票,并计划在 15.8 版中为 .NET Core 项目引入上下文菜单选项:
Manish Jayaswal [MSFT] replying to Daniel Tibi · Apr 06 2018 at 10:30 PM
Getting this functionality added to .NET Core projects requires some
significant changes in the new project system - which drives the .NET
Core projects. This work is getting tracked in project system GitHub
repo in this issue
(https://github.com/dotnet/project-system/issues/3425) . This issue is
expected to be resolved in 15.8 release timeframe so unfortunately,
create unit test functionality for .NET Core projects would not be
available in the upcoming 15.7 release. We fully understand that this
is a key feature and would do our best to make it available as early
as possible.
2018 年 7 月更新
Create unit test method stubs with the Create Unit Tests command page has been updated now 反映这不适用于 .NET Core。
2018 年 8 月更新
正如@gartenriese below, the GitHub issue 3425 Microsoft described as tracking this work was moved to the 15.9 milestone on 02 August 2018所指出的那样。
2019 年 1 月更新
单元测试功能似乎依赖于或被 another part of the development. That part is now slated for VS 16.1, i.e VS 2019, and is also further down the priority list than EF Core 3.0 (which is one of the main features of VS 16) according to this GitHub post by Microsoft's David Kean 阻止。
2019 年 5 月更新
面向 .NET Core 和 .NET Standard 的项目(尚)不支持“创建单元测试”上下文菜单选项。
文档是 updated to reflect this in July 2018,现在声明:
The Create Unit Tests menu command:
- Is available in the Community, Professional, and Enterprise Editions of Visual Studio 2015 and later.
- Supports only C# code that targets the .NET Framework.
- Is extensible, and supports emitting tests in MSTest, MSTest V2, NUnit, xUnit format.
- Is not yet available in .NET Core projects.
此功能是 slated for release in Version 15.9 of Visual Studio, but now appears to have been pushed back to Version 16.1。
我已经在 Visual Studio Professional 2019 RC(版本 16.0.0)的 .NET Core 2.2 项目中对此进行了测试,我可以确认它仍然无法正常工作 - 正如上述答案所预期的那样。
我也刚刚测试了 Visual Studio Professional 2019 Preview(版本 16.1.0 Preview 2.0),它在那里也不可用,所以看起来 Microsoft 还没有做到这一点。
我知道这个问题之前已经在 SO 上被问过,而且这个功能似乎在某个时候从 VS 中删除了。但是我现在正在查看 Microsoft tutorial,它说 VS 2017 中应该有一个创建单元测试功能。
我正在尝试测试 ASP.NET 核心 MVC 控制器。我已按照创建测试项目的步骤进行操作。但是当我右键单击 namespace/class/method.
时,我仍然看不到任何这样的选项编辑:我正在使用 Visual Studio 2017 社区版
以下答案仅与 .NET Core/Standard 相关。如果您缺少完整 .NET Framework 项目的“创建单元测试”选项
当前状态:现在可用于 .NET Core!
我现在在 Visual Studio Professional 2019 版本 16.3.0 预览版 3.0 上的 Core 3 解决方案 运行 中有创建单元测试上下文菜单。不确定它何时重新出现,因为我一直在定期更新每个新的预览版本。
历史
有关更多历史记录和详细信息,请参阅下面的更新。
原始答案 2017 年 6 月
来自 Microsoft's Jayarani Garg 的 GitHub 条目确认它仅适用于针对完整 .NET 框架的项目:
Jayarani Garg [MSFT] · Feb 27 2017 at 06:09 AM Hi,
Thank you for your feedback. "Create Unit Test" is currently not supported for .Net Core projects.
根据同一 Visual Studio 开发者社区页面上的 this Visual Studio Team comment,这是设计使然,而不是错误:
Visual Studio Team ♦♦ · Mar 10 2017 at 01:06 PM
Thank you for your feedback! The Visual Studio team has determined that this issue is not a bug. However, we will consider this feedback and have created https://github.com/Microsoft/vstest/issues/592 to track this. Please feel free to vote for the issue.
上面提到的 Microsoft VS 测试存储库 Create Unit Test Context Menu Missing (.net core projects) is slightly confusing. It's asking for this feature to be added for .NET Core projects too but then a Microsoft employees talk about having a fix for an issue. I believe that employee is referring to the old bug where the context menu option wasn't working for full .NET framework projects either
我也刚刚查看了 Visual Studio Professional 2017 版本 15.2 (26430.6) 的副本,我 do 有一个项目的创建单元测试选项以完整的 .NET 框架为目标(这个以 .NET Framework 4.5.1 为目标):
但是我没有针对 .NETCoreApp 1.1 的项目:
2018 年 6 月更新
Microsoft 已注意到 feature request 的投票,并计划在 15.8 版中为 .NET Core 项目引入上下文菜单选项:
Manish Jayaswal [MSFT] replying to Daniel Tibi · Apr 06 2018 at 10:30 PM
Getting this functionality added to .NET Core projects requires some significant changes in the new project system - which drives the .NET Core projects. This work is getting tracked in project system GitHub repo in this issue (https://github.com/dotnet/project-system/issues/3425) . This issue is expected to be resolved in 15.8 release timeframe so unfortunately, create unit test functionality for .NET Core projects would not be available in the upcoming 15.7 release. We fully understand that this is a key feature and would do our best to make it available as early as possible.
2018 年 7 月更新
Create unit test method stubs with the Create Unit Tests command page has been updated now 反映这不适用于 .NET Core。
2018 年 8 月更新
正如@gartenriese below, the GitHub issue 3425 Microsoft described as tracking this work was moved to the 15.9 milestone on 02 August 2018所指出的那样。
2019 年 1 月更新
单元测试功能似乎依赖于或被 another part of the development. That part is now slated for VS 16.1, i.e VS 2019, and is also further down the priority list than EF Core 3.0 (which is one of the main features of VS 16) according to this GitHub post by Microsoft's David Kean 阻止。
2019 年 5 月更新
面向 .NET Core 和 .NET Standard 的项目(尚)不支持“创建单元测试”上下文菜单选项。
文档是 updated to reflect this in July 2018,现在声明:
The Create Unit Tests menu command:
- Is available in the Community, Professional, and Enterprise Editions of Visual Studio 2015 and later.
- Supports only C# code that targets the .NET Framework.
- Is extensible, and supports emitting tests in MSTest, MSTest V2, NUnit, xUnit format.
- Is not yet available in .NET Core projects.
此功能是 slated for release in Version 15.9 of Visual Studio, but now appears to have been pushed back to Version 16.1。
我已经在 Visual Studio Professional 2019 RC(版本 16.0.0)的 .NET Core 2.2 项目中对此进行了测试,我可以确认它仍然无法正常工作 - 正如上述答案所预期的那样。
我也刚刚测试了 Visual Studio Professional 2019 Preview(版本 16.1.0 Preview 2.0),它在那里也不可用,所以看起来 Microsoft 还没有做到这一点。