是否有“动态播放列表"? Visual Studio中的单元测试? [英] Are there "Dynamic Playlists" of unit tests in Visual Studio?

查看:97
本文介绍了是否有“动态播放列表"? Visual Studio中的单元测试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Visual Studio中使用单元测试时,可以编译将测试分组的播放列表.例如,这在开发新功能时非常有用,而我们只希望针对该功能运行相关的测试,而不是所有现有的测试.

但是,在我看来,播放列表只能通过显式添加/删除单元测试来手动"维护.

总比没有好,但是如果我能根据某种标准(例如功能,测试持续时间等)如何标记"单元测试并动态生成播放列表,那就太好了.

是否可以使用默认的测试框架在Visual Studio中执行类似的操作?

解决方案

您可以通过右键单击然后运行测试",或者按CTRL + R再按T,相对于当前光标位置在上下文中运行某些测试. >

  • 如果光标位于测试的主体内,则仅运行该测试.
  • 如果光标位于测试类的主体内,则仅运行该类中的测试.
  • 如果光标位于名称空间内,则将运行该名称空间中的所有测试.

有关该主题,请参见 MSDN文档.

>

或者,您可以通过多种方式过滤测试浏览器 .例如,我经常使用Project标志来排除某些项目.

When working with unit tests in Visual Studio, it's possible to compile playlists that group the tests. This is useful, for instance, when developing a new feature for which we want to run only the related tests and not all the existing ones.

However, it seems to me the playlists can only be maintained "manually", by explicitly adding/removing unit tests.

It's better than nothing, but it would be great if I could some how "tag" my unit tests depending on some criterion (e.g. feature, test duration, etc.) and generate the playlists dynamically.

Is there any way to do something similar in Visual Studio with the default testing framework?

解决方案

You can run certain tests contextually in relation to the current cursor position by right clicking and then "Run Tests", or hitting CTRL+R then T.

  • If the cursor is within the body of a test, only that test will be run.
  • If the cursor is within the body of a test class, only the tests in that class will be run.
  • If the cursor is within a namespace, all tests in that namespace will be run.

See MSDN documentation on the subject.

Alternatively you can filter the test explorer in various ways. I often use the Project flag to exclude certain projects for instance.

这篇关于是否有“动态播放列表"? Visual Studio中的单元测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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