您更关注单元测试、集成测试还是验收测试?

发布于 2024-07-14 19:23:15 字数 258 浏览 7 评论 0原文

我最终参加的大多数工作都很少或根本没有单元测试。 通常,所描述的单元测试实际上是集成测试,并且很少从开发人员计算机上运行。 我通常通过宣扬两者之间的差异来开始我的传播,并尝试让人们编写非常集中的单元测试,并将集成测试留到以后,即当有足够多的人编写单元测试时,我们可以“继续”编写集成测试。 验收或系统级测试通常由开发人员手动处理,然后由 QA 部门手动处理。

我的问题是,当在敏捷环境之外工作时,您在单元测试、集成测试和验收测试上投入了多少精力,以及您认为什么最有价值?

Most gigs I end up at either have little or no unit tests. Typically what are described as the unit tests are actually integration tests and will be rarely run from the developers machine. I usually start my evangelism by preaching the difference between the two and try to get people to write very focussed unit tests and leave the integration tests for later, i.e. when enough people are writing unit tests that we can "move on" to writing the integration tests. Acceptance or system level tests are usually handled manually by the developer and then by the QA department.

My question is when working outside of an Agile environment, how much effort do you put into unit, integration and acceptance tests and what do you see the most value from?

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

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

发布评论

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

评论(4

半世蒼涼 2024-07-21 19:23:15

我尝试从一开始就进行单元测试。 我不是世界上最大的 TDD 粉丝,但我真的很喜欢单元测试。 我不认为某个魔法仙女会确保集成测试能够顺利通过,因为所有单元测试都有效,但它已经非常接近了。

至于验收测试,我什至不会查看某些内容,直到看到单元测试通过(或失败,如果它们应该失败)。 我想不出有多少情况我会接受完全缺乏单元测试。 如果应用程序中的某些核心库更新怎么办?

许多人会认为单元测试是以开发人员为中心的,他们是正确的。 然而,缺乏单元测试本身就是一个指标..特别是如果进行验收测试的人恰好是一名开发人员:)

编辑:

集成测试对我来说也很重要。 我们通常按照非常严格的规范来构建东西。当集成测试失败时(在之前通过之后),这是范围蔓延的强烈指标。 当这种情况发生时,有人需要在修复它之前发出一些声音。

I try to pound on unit tests from the beginning. I'm not the world's biggest TDD fan, but I really harp on unit tests. I don't think some magic fairy is going to ensure that integration testing is going to pass with flying colors because all of the unit tests work, but it gets pretty darn close.

As for acceptance testing, I'm not even going to look at something until I see the unit tests pass (or fail, if they are supposed to fail). I can't think of many cases that I'd accept a complete lack of unit tests. What if some core lib in the application updates?

Many will argue that unit tests are developer centric, they would be correct. However, a lack of unit tests is an indicator all on its own .. especially if the one doing acceptance tests happens to be a developer :)

Edit:

Integration tests are also important to me. We typically build things to a very tight spec .. when integration tests fail (after previously passing), its a strong indicator of scope creep. When that happens, someone needs to make some noise prior to just fixing it.

盛夏尉蓝 2024-07-21 19:23:15

这个问题的答案常常会走极端。 就像你应该有几乎 100% 的覆盖率,或者单元测试很愚蠢......

我相信你必须找到平衡。

如果有合理理由怀疑类的逻辑可能会失败,请使用单元测试。 单元测试必须在隔离的类上完成,因此这意味着您可能需要模拟该类使用的服务。 这样您就可以安全地执行重构,因为单元测试将确保该类仍然按预期工作。

集成测试对于确保您的应用程序正常运行是必要的。 您可以进行多次单元测试,但这并不意味着您的应用程序将正常工作。

我完全同意你关于验收测试的观点。 在(冲刺)结束时执行这些操作,并且部分操作必须手动完成。

Very often answer to this question goes to extreme. Like you should have coverage almost 100% or unit tests are stupid....

I believe that you have to find balance.

Use unit tests where there is reasonable doubt that logic of the class can fail. Unit tests must be done on isolated class so it means that you probably need to mock services that class uses. This way you will feel safe to perform refactoring because unit tests will ensure that class still works as expected.

Integration tests are necessary to ensure that you application works at all. You can have number of unit tests but it does not mean that you application will work correctly.

I completely agree with you regarding acceptance test. Do them at the end (of sprint) and partially they must be done manually.

尽揽少女心 2024-07-21 19:23:15

我听说单元测试就像测试墙上的各个砖块,而功能/集成测试就像测试整个墙的稳定性。

单元测试对于开发人员来说是必要的,以确保类正在做他们应该做的事情。

功能/集成测试是必要的,以确保您不会错过实际提供某些功能的“大局”目标。

因此,恕我直言,两者都是绝对必要的,从投资回报率的角度来看,忽略其中任何一个都是一个坏主意。

I heard the comparison that unit tests are like testing the individual bricks in your wall and functional/integration tests are like testing the entire wall for stability.

The unit tests are necessary for the developers to make sure the classes are doing what they're supposed to.

The functional/integration tests are necessary to make sure you're not missing the "big picture" goal of actually providing certain functions.

So IMHO, both are absolutely necessary and from a ROI perspective it would be a bad idea to leave either out.

梦魇绽荼蘼 2024-07-21 19:23:15

我认为你不能把它混为一谈。 您描述的每个测试都有不同的目标。

单元测试是针对开发人员的。 他们在模块实现之前或并行编写单元测试,以确保模块正常工作或满足所有接口和要求。

测试中心开发完成后进行集成测试。 您不会像开发期间的单元测试那样测试单个模块。 集成测试涵盖多个模块之间的交互。

验收测试通常需要客户亲自检查是否满足所有要求以及是否按指定实施功能。

I think you can't mix it up. Each of the tests you have described have a different target.

Unit Test are target to developers. They write a unit test before or parallel to the implementation of a module to ensure it works or all interfaces and requirements are fulfilled.

A integration test is done after development from the test center. You don't test a single module like in a unit test during development. The integration test is covering the interaction between several modules.

A acceptance test often involves the customer himself to check if all requirements are fulfilled and features are implemented like specified.

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