VS 2017中的创建单元测试在哪里? [英] Where is Create Unit Test in VS 2017?

查看:97
本文介绍了VS 2017中的创建单元测试在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道在SO上曾有人问过这个问题,而且似乎在VS上已删除了此功能。但我正在查看Microsoft



但我不要将其用于针对.NETCoreApp 1.1的项目:





2018年6月更新



Microsoft已经注意到功能请求,并计划引入.NET Core的上下文菜单选项版本15.8中的项目:


Manish Jayaswal [MSFT]回复Daniel Tibi·2018年4月6日晚上10:30



要将此功能添加到.NET Core项目中,需要对新项目系统进行
的重大更改-这将驱动.NET
Core项目。在本期
中,该工作正在项目系统GitHub
回购中进行跟踪( https://github.com/dotnet/project-system/issues/3425 )。预计
的问题将在15.8版本的发布时间内解决,因此,不幸的是,在即将到来的15.7版本中,
无法为.NET Core项目创建单元测试功能。我们完全理解,此
是一项关键功能,将尽我们所能使它尽可能早地投入使用。




2018年7月更新



使用创建单元测试命令页面创建单元测试方法存根具有现已更新,以反映这不适用于.NET Core。


$ b

2018年8月更新



@gartenriese 在下面,Microsoft描述为跟踪此工作的GitHub问题3425已移至 15.9

2019年1月更新



单元测试功能似乎是依赖或受开发的另一部分阻止。该部分现已定于VS 16.1,即VS 2019,并且比EF Core 3.0(这是VS 16的主要功能之一)的优先级列表要低得多。根据Microsoft的David Kean的GitHub帖子



2019年5月更新



面向.NET Core和.NET Standard的项目尚不支持创建单元测试上下文菜单选项。



文档为在2018年7月 ,现在指出:


创建单元测试菜单命令:




  • 在Visual Studio 2015的社区版,专业版和企业版中可用。

  • Sup仅移植针对.NET Framework的C#代码。

  • 是可扩展的,并支持以MSTest,MSTest V2,NUnit和xUnit格式发射测试。

  • .NET Core项目中尚不可用。


此该功能计划在Visual Studio的15.9版中发布,但现在似乎已被推回到版本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),它也不可用,因此不看起来微软已经做到了。


I understand that this question has been asked before on SO and it appears that this feature was removed from VS at some point. But I am looking at a Microsoft tutorial right now and that says there should be a Create Unit Test function in VS 2017.

I'm trying to test ASP.NET Core MVC controllers. I have followed the steps for creating a test project. But I still can't see any such option when I right click a namespace/class/method.

EDIT: I'm using Visual Studio 2017 Community Edition

解决方案

The answer below relates to .NET Core/Standard only. If you're missing the Create Unit Tests option for a full .NET Framework project see here.

Current status: It's now working for .NET Core!

I now have the Create Unit Tests context menu in my Core 3 solution running on Visual Studio Professional 2019 Version 16.3.0 Preview 3.0. Not sure exactly when it reappeared as I've been updating regularly with each new preview version.

History

See the updates below for more history and details.

Original answer June 2017

This GitHub entry from Microsoft's Jayarani Garg, confirmed it is only available for projects targeting the full .NET framework:

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.

That's by design rather than a bug according to this Visual Studio Team comment on that same Visual Studio Developer Community page:

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.

The github issue referred to above on the Microsoft VS Test repo 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 as discussed in this question which is also mentioned in that thread. As far as I can see that thread is not saying they've added the menu option for .NET Core projects.

I've also just checked on a copy of Visual Studio Professional 2017, version 15.2 (26430.6) and I do have the Create Unit Tests option for a project that targets the full .NET framework (this one targets .NET Framework 4.5.1):

But I don't have it for a project that targets .NETCoreApp 1.1:

Update June 2018

Microsoft have taken notice of the upvotes for the feature request and are planning to introduce the context menu option for .NET Core projects in release 15.8:

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.

Update July 2018

The Create unit test method stubs with the Create Unit Tests command page has been updated now to reflect that this doesn't work for .NET Core.

Update August 2018

As pointed out by @gartenriese below, the GitHub issue 3425 Microsoft described as tracking this work was moved to the 15.9 milestone on 02 August 2018.

Update January 2019

The unit testing feature seems to be reliant on, or blocked by, 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.

May 2019 update

The Create Unit Tests context menu option isn't supported (yet) for projects that target .NET Core and .NET Standard.

The documentation was updated to reflect this in July 2018 and now states:

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.

This feature was slated for release in Version 15.9 of Visual Studio, but now appears to have been pushed back to Version 16.1.

I've tested this in a .NET Core 2.2 project in Visual Studio Professional 2019 RC (version 16.0.0) and I can confirm it's still not working there - as expected as per the above answer.

I've also just tested Visual Studio Professional 2019 Preview (version 16.1.0 Preview 2.0) and it's not available there either, so it doesn't look like Microsoft have got to this yet.

这篇关于VS 2017中的创建单元测试在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆