在 MSTest 的测试视图中,如何获取没有类别的所有测试的列表?

发布于 2024-10-03 13:09:01 字数 245 浏览 0 评论 0原文

我正在使用 MSTest,大多数单元测试都没有 TestCategory 属性,但我想将一些测试放入“慢”类别中。然后我希望能够轻松运行所有未分配类别的测试。

当我进入测试视图时,我可以按测试类别进行过滤,但无法输入空关键字。我可以轻松找到“慢”的,但如何找到非慢的?我试图避免将测试类别放在我的所有测试中。

我想如果我必须……搜索和替换应该可以找到所有内容,那也不是世界末日,但如果有办法找到未分类的内容,我想知道。

I'm using MSTest and most of my unit tests have no TestCategory attribute, but I want to put a few tests into a "Slow" category. Then I want to be able to easily run all the tests that have no category assigned.

When I go to Test View, I can filter by Test Categories, but I can't put in a keyword of empty. I can easily find my "Slow" ones, but how to I find my non-Slow ones? I'm trying to avoid putting a test category on all my tests.

I guess it's not the end of the world if I have to... a search and replace should get them all, but if there's a way to find the non-categorized, I would like to know.

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

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

发布评论

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

评论(3

掌心的温暖 2024-10-10 13:09:01

您还可以从命令行中排除这些测试。

mstest /testcontainer:foo.tests.dll /category:!Slow

You can also exclude these tests from the command line.

mstest /testcontainer:foo.tests.dll /category:!Slow
你的笑 2024-10-10 13:09:01

在测试列表编辑器中,将“测试类别”添加为一列,按“无”分组,然后按“测试类别”排序。没有类别的测试将位于顶部。不幸的是,您无法按测试类别进行分组。

In the test list editor, add Test Categories as a column, group by None, and sort on Test Categories. Tests with no categories will be at the top. Unfortunately, you can't group by Test Category.

小ぇ时光︴ 2024-10-10 13:09:01

看来 /category:!Slow 根本不起作用。坏事!
因此,有必要将例如 [TestCategory("unit")] 属性添加到所有测试中。

另一种更好的方法是按项目分离单元测试和集成测试,并单独运行此类测试。

It seems that /category:!Slow doesn't work at all. Bad thing!
So it's necessary to put, for example [TestCategory("unit")] attribute to all of the tests.

Another, better way is to separate unit and integration tests by projects and run such tests separately.

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