对 MsTest 用例进行分类

发布于 2024-08-08 16:10:39 字数 517 浏览 2 评论 0原文

我正在寻找最简单的方法来对我的测试进行分类,以便我可以单独运行它们。

我的组织将类似于以下

  • 单元测试
  • 集成测试
  • 系统测试

这样做的原因是我们所有的测试还没有发展到完全自动化。我们的大多数单元测试都是完全自动化的,而集成系统测试则不是。然而,所有测试对于在开发人员机器上调用仍然有用。

为简单起见,我希望我们可以使用独特的属性 [IntegrationTest][TestCategory("Integration")] 提交不同类型的测试,这样我们的构建服务器就可以了只运行我们想要的测试。

我知道 nUnit 有测试类别,但我们的团队喜欢 MsTest + IDE 集成的 Microsoft Stamp 批准。

您的团队是如何解决这个问题的?
是否有提供此功能的扩展?
这会内置到 .Net 4.0 中吗?

谢谢

I'm looking for the easiest way to categorize my tests so I can run them separately.

My organization would be something like the following

  • Units Tests
  • Integrations Tests
  • Systems Test

The reasoning for this is all our testing hasn't evolved to be completely automated yet. Most of our unit tests are completely automated, while integration and system tests aren't. However all tests are still useful to invoke on developers machines.

For simplicity I'd like it if we could just commit our different types of tests with distinctive attributes [IntegrationTest] or [TestCategory("Integration")] so our build server only runs the tests we want.

I'm aware nUnit has test categories but our team likes the Microsoft Stamp of approval on MsTest + IDE integration.

How has your team solved this problem?
Are there extensions that provide this functionality?
Will this be built into .Net 4.0?

Thanks

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

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

发布评论

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

评论(3

失去的东西太少 2024-08-15 16:10:39

您看过测试列表功能吗?单击测试->窗口 ->测试列表编辑器 打开用于管理测试列表的 UI。右键单击测试列表并选择新测试列表为其命名并保存。然后,将测试拖到新组中,创建可以一起运行的所有测试的子集。

另一种选择是使用“测试视图”工具窗口的过滤功能来选择具有相似特征的测试。它将匹配部分内容,因此您可以切换到测试名称并输入“Asp”之类的内容来匹配包含该字符串的所有测试,然后通过选择所有过滤的项目来一起运行结果。缺点是您可能必须重新命名您的测试。

同样,并且更接近您的想法,您可以右键单击“测试视图”窗口中的测试,选择“属性”并填充“说明” > 属性或按照您的建议通过使用 Description 属性装饰测试。之后您可以使用之前的方法来过滤测试(这次过滤Description),尽管不是该字段的预期用途,但它可以达到您想要的结果

Have you looked at the Test Lists feature? Click Test -> Windows -> Test List Editor to bring up the UI for managing test lists. Right click List of Tests and choose New Test List giving it a name and saving. Afterward you drag tests into the new group creating a subset of All Tests that can be run together.

Another option is to use the filter feature of the Test View tool window to select tests with similar traits. It will match partials, so you can switch to Test Name and enter something like "Asp" to match all tests containing that string and then run the results together by making a selection of all filtered items. The downside is you'd potentially have to rename your tests.

Along the same lines, and closer to what you were thinking, you could right click tests in the Test View window, choose Properties and populate the Description property or as you suggested by decorating tests with the Description attribute. Afterward you use can use the prior approach to filter tests (this time filtering on Description) albeit not the intended use of the field, it could achieve your desired result

夜声 2024-08-15 16:10:39

这些基本上是不同类型的测试,因此应该放置在不同的项目中。

有很多充分的理由将集成测试和单元测试分开,这在这种情况下也会有所帮助。

  • 每个接受测试的类库应该有一个(或多个)相关的单元测试项目。
  • 集成测试应该进入一个(或多个)单独的测试项目,以便您可以根据需要改变它们。

您可以拥有不同的解决方案文件,其中包含一些测试项目,但排除其他测试项目,具体取决于您希望运行的测试套件的类型。

请注意,此策略将与 MSTest 以及您将来可能决定使用的任何其他测试框架一起使用,我认为这是一个额外的好处。

These are basically different types of tests and thus should be placed in different projects.

There are a lot of good reasons to keep integration tests and unit tests separate, and it will also help in this case.

  • Each class library subjected to testing should have one (or more) associated unit test projects.
  • Integration tests should go into one (or more) separate test projects so that you can vary them as you need.

You can have different solution files that include some, but exclude other test projectz depending on the type of test suite you wish to run.

Note that this strategy will work with MSTest any other testing framework you may decide to use in the future, which I would consider an extra benefit.

明媚殇 2024-08-15 16:10:39

是的,.NET 4.0 Beta 2 中有一个 TestCategory 属性(RTM 中不会排除它,因为 Beta 2 功能完整,据我所知)

http://msdn.microsoft.com/en-us/library/ms182489%28VS.100%29.aspx

Yes, there is a TestCategory attribute in .NET 4.0 Beta 2 (it won't be ruled out in RTM as Beta 2 is feature complete AFAIK)

http://msdn.microsoft.com/en-us/library/ms182489%28VS.100%29.aspx

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