我应该将单元测试和集成测试分成单独的项目吗

发布于 2024-12-23 00:05:17 字数 1431 浏览 1 评论 0原文

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

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

发布评论

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

评论(3

独夜无伴 2024-12-30 00:05:17

取决于您的测试框架和持续集成环境以及您是否想要通过单元测试执行集成测试。

MbUnit、NUnit 和 MSTest 等测试框架支持用类别标记测试的概念,这意味着您可以通过用自己的类别(即“集成”)标记哪些测试来指示哪些测试是集成测试。类别使得可以将两组测试保留在同一项目中,但使用配置设置来控制在构建服务器上运行哪组测试。

就我个人而言,我喜欢仅在必要时将它们分成单独的项目。例如,如果集成测试需要自己的特殊项目依赖项,或者如果我想简化构建服务器的配置,以便仅定期运行集成测试,我可能会将其拆分为自己的项目。

Depends on your test framework and continuous integration environment and whether you want to execute your integration tests with your unit tests.

Test frameworks like MbUnit, NUnit and MSTest support the concept of tagging tests with categories, meaning you could indiciate which tests were integration tests by marking them with their own category, ie "Integration". Categories make it possible to keep both sets of tests in the same project but use configuration settings to control which set of tests are run on the build server.

Personally, I like to split them out into separate projects only when necessary. For example, I might split then into their own project if the integration tests required their own special project dependencies or if I wanted to simplify the configuration of the build server such that integration tests are only run periodically.

允世 2024-12-30 00:05:17

取决于“项目”的范围。单个项目的组件的集成测试应该在项目内进行。测试多个项目相互集成的测试应该是一个单独的项目。

Depends on the scope of a "project". The integration tests for the components of a single project should be within the project. The tests testing the integration of multiple projects with each other should be a separate project.

救星 2024-12-30 00:05:17

我认为 int 测试和单元测试应该是单独的文件。您不知道 SUT 中的类何时会被换出。单独的单元测试减少了所需的重构。

It is my opinion that int tests and unit tests should be separate files. You don't know when a class in your SUT will be swapped out. Separate unit tests reduce the refactoring needed.

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