何时进行单元测试与手动测试 [英] When to unit-test vs manual test

查看:36
本文介绍了何时进行单元测试与手动测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

虽然单元测试对于 API 需要具有工业实力的大型项目(例如 .Net 框架 API 的开发等)似乎很有效,但对于较小的项目来说似乎有点过头了.

While unit-testing seems effective for larger projects where the APIs need to be industrial strength (for example development of the .Net framework APIs, etc.), it seems possibly like overkill on smaller projects.

什么时候自动化 TDD 方法是最好的方法,什么时候只使用手动测试技术、记录错误、分类、修复它们等会更好.

另一个问题——当我在 Microsoft 担任测试人员时,有人向我们强调,让开发人员和测试人员成为不同的人是很有价值的,这两个群体之间的紧张关系有助于在结束.TDD 能否打破这种想法并造成一种情况,即开发人员可能不是严格找出自己错误的合适人选?它可能是自动化的,但似乎有很多方法可以编写测试,而且一组给定的测试是否会证明"质量是可以接受的,这是值得怀疑的.

Another issue--when I was a tester at Microsoft, it was emphasized to us that there was a value in having the developers and testers be different people, and that the tension between these two groups could help create a great product in the end. Can TDD break this idea and create a situation where a developer might not be the right person to rigorously find their own mistakes? It may be automated, but it would seem that there are many ways to write the tests, and that it is questionable whether a given set of tests will "prove" that quality is acceptable.

推荐答案

TDD 的有效性与项目大小无关.即使在最小的编程练习中,我也会实践TDD 的三个定律.编写测试不需要太多时间,并且可以节省大量调试时间.它们还允许我重构代码而不必担心破坏任何东西.

The effectiveness of TDD is independent of project size. I will practice the three laws of TDD even on the smallest programming exercise. The tests don't take much time to write, and they save an enormous amount of debugging time. They also allow me to refactor the code without fear of breaking anything.

TDD 是一门类似于会计师实践的双记账簿的学科.它可以防止小错误.会计师将每笔交易录入两次;一次作为贷方,一次作为借方.如果没有出现简单的错误,那么资产负债表的总和将为零.零是一个简单的抽查,可以防止高管入狱.

TDD is a discipline similar to the discipline of dual-entry-bookkeeping practiced by accountants. It prevents errors in-the-small. Accountants will enter every transaction twice; once as a credit, and once as a debit. If no simple errors were made, then the balance sheet will sum to zero. That zero is a simple spot check that prevents the executives from going to jail.

同样,程序员在编写代码之前编写单元测试作为简单的抽查.实际上,他们将每一位代码编写两次;一次作为测试,一次作为生产代码.如果测试通过,则这两位代码是一致的.这两种做法都不能防止更大和更复杂的错误,但两种做法都很有价值.

By the same token programmers write unit tests in advance of their code as a simple spot check. In effect, they write each bit of code twice; once as a test, and once as production code. If the tests pass, the two bits of code are in agreement. Neither practice protects against larger and more complex errors, but both practices are nonetheless valuable.

TDD 的实践并不是真正的测试技术,而是一种开发实践.TDD 中的测试"一词或多或少是一个巧合.因此,TDD 不能替代良好的测试实践和优秀的 QA 测试人员.事实上,让有经验的测试人员独立(通常在编写代码(及其单元测试)的程序员之前)编写 QA 测试计划是一个非常好的主意.

The practice of TDD is not really a testing technique, it is a development practice. The word "test" in TDD is more or less a coincidence. As such, TDD is not a replacement for good testing practices, and good QA testers. Indeed, it is a very good idea to have experienced testers write QA test plans independently (and often in advance of) the programmers writing the code (and their unit tests).

我更喜欢(实际上是我的热情)这些独立的 QA 测试也使用像 FitNesse 这样的工具自动化,SeleniumWatir.这些测试应该易于业务人员阅读、易于执行且完全不含糊.您应该能够立即运行它们,通常每天运行多次.

It is my preference (indeed my passion) that these independent QA tests are also automated using a tool like FitNesse, Selenium, or Watir. The tests should be easy to read by business people, easy to execute, and utterly unambiguous. You should be able to run them at a moment's notice, usually many times per day.

每个系统也需要手动测试.然而,手动测试不应该是死记硬背.可以编写脚本的测试应该是自动化的.您只想在需要人工判断时让人工参与.因此,人类应该进行探索性测试,而不是盲目遵循测试计划.

Every system also needs to be tested manually. However, manual testing should never be rote. A test that can be scripted should be automated. You only want to put humans in the loop when human judgement is needed. Therefore humans should be doing exploratory testing, not blindly following test plans.

因此,对于何时进行单元测试与手动测试的问题的简短回答是没有对抗".您应该首先为您编写的绝大多数代码编写自动化单元测试.您应该拥有由测试人员编写的自动化 QA 验收测试.您还应该练习战略性探索性手动测试.

So, the short answer to the question of when to unit-test versus manual test is that there is no "versus". You should write automated unit tests first for the vast majority of the code you write. You should have automated QA acceptance tests written by testers. And you should also practice strategic exploratory manual testing.

这篇关于何时进行单元测试与手动测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆