在Visual Studio测试中,如何制作自动排除某些测试的播放列表? [英] In Visual Studio Test, how to make a playlist which automatically excludes certain tests?

查看:105
本文介绍了在Visual Studio测试中,如何制作自动排除某些测试的播放列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的团队拥有Visual Studio 2012 Professional许可证(非Test Professional).我们正在开发一个较小的Web应用程序,我们既有可模拟所有所需内容的真实单元测试,也有数据层测试.每一类数据层测试都从头开始创建整个数据库,并用一组准备好的测试数据填充它,因此运行它们将花费很长时间.结果,我们不愿意执行全部运行",并且很少使用我们的单元测试(快速).

Our team has Visual Studio 2012 Professional licenses (not Test Professional). We are developing a smallish web application, and we have both true unit tests which mock everything needed, and tests for the data layer. Each class of data layer tests creates the whole database from scratch and fills it with a prepared set of test data, so running them takes a long time. As a result, we are reluctant to do a "run all", and our unit tests (which are quick) are only used rarely.

我们正在寻找一种低摩擦的解决方案,该解决方案将使我们能够以2-3次点击(类似于现有的全部运行")来运行所有快速测试,并在需要时轻松地运行所有测试.

We are looking for a low-friction solution which will allow us to run all quick tests with 2-3 clicks (similar to the existing Run all) frequently, and easily run all tests when needed.

我们尝试仅制作快速测试的播放列表.但是我们已经完成了对数据层的编程,因此实际上我们编写的所有新测试都是快速测试,并且将它们添加到播放列表中很烦人,而且容易出错.我们宁愿选择一种方法,以某种方式将快速运行"中不需要的测试标记为已排除,并自动运行解决方案中的所有其他测试.请注意,我们不想为慢速测试永久添加忽略"属性,因为我们仍然希望每天至少运行一次.

We tried making a playlist of the quick tests only. But we are done with programming the data layer, so practically all new tests we write are quick tests, and adding each of them to the playlist is annoying and somewhat error-prone. We would prefer an approach where we somehow mark the tests we do not want in a "quick run" as excluded, and it automatically runs all other tests in the solution. Note that we don't want to permanently add an Ignore attribute to the slow tests, as we still want to run them at least once daily.

推荐答案

您可以使用mstest中的特征"功能来完成此任务.看一下这篇博客文章:

You could use the Traits feature in mstest to accomplish this. Take a look at this blog post: http://blogs.msdn.com/b/visualstudioalm/archive/2012/11/09/how-to-manage-unit-tests-in-visual-studio-2012-update-1-part-1-using-traits-in-the-unit-test-explorer.aspx

这篇关于在Visual Studio测试中,如何制作自动排除某些测试的播放列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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