MSTEST/Visual Studio 中 PriorityAttribute 的用途是什么

发布于 2024-07-19 04:02:27 字数 190 浏览 2 评论 0原文

我注意到 Microsoft.VisualStudio.TestTools.UnitTesting.PriorityAttribute 的存在。 从阅读的内容来看,它似乎与测试执行顺序没有任何关系。 既然如此,这就引出了一个问题:它是用来做什么的?

我很好奇,Visual Studio 本身或任何插件/框架是否有任何已知的此属性的用途。

I noticed the existence of Microsoft.VisualStudio.TestTools.UnitTesting.PriorityAttribute. From reading a little about it, it does not seem to have anything to do with the test execution order. That being the case, it begs the question: what is it used for?

I'm curious, are there any known uses of this attribute either by Visual Studio itself of any plugins/frameworks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

荒芜了季节 2024-07-26 04:02:27

它只是额外的元数据,目前不用于任何特定的用途。 影响测试顺序的唯一因素是使用有序测试

Its just extra metadata its not used for anything specific right now. The only thing that impacts the ordering of tests is using an ordered test

絕版丫頭 2024-07-26 04:02:27

在 Visual Studio 2012 测试资源管理器工具窗口中,当您选择“特征”视图时,会显示测试优先级和测试类别。 具有相同优先级的测试将被分组在 Priority [x] 标题下,就像测试类别一样。

此外,mstest(Visual Studio 中包含的命令行测试运行程序)允许您仅运行具有最低优先级的测试。 从 mstest.exe /? 的输出:

/minpriority:[priority]       Only tests whose priority is greater than
                              or equal to this value will be executed.
                              Example:
                              /minpriority:0 /maxpriority:2

In the Visual Studio 2012 Test Explorer tool window, both test priorities and test categories are shown when you select the "Traits" view. Tests with the same priority will then be grouped together under a Priority [x] heading, just like test categories.

Also, mstest (the command line test runner included in visual studio) allows you to run only tests with a minimum priority. From the output of mstest.exe /?:

/minpriority:[priority]       Only tests whose priority is greater than
                              or equal to this value will be executed.
                              Example:
                              /minpriority:0 /maxpriority:2
安稳善良 2024-07-26 04:02:27

它可以在构建定义(用于构建服务器上的构建)中使用来排除或包含单元测试(至少在 tfs 2010 中)。

It can be used in Build Definitions (for builds on a build server) to exclude or include unit tests (a least in tfs 2010).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文