本文介绍了我为什么要这两个单元测试,通过(而不仅仅是网络测试)Web测试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在的位置是这样的:如果我彻底地(通过VS.NET'08测试工具和华廷在我的情况,也许)与code覆盖和广谱测试使用Web测试我的ASP.NET应用程序的数据,我应该没有必要写个人的单元测试,因为我的code将结合通过所有层UI进行测试。 code覆盖率将确保我打code的各功能块(或透露未使用code)和我可以提供,这将覆盖所有合理预期的条件的数据。

不过,如果你有不同的意见,我想知道:


  1. 什么的其他的利益不单元测试给予了证明的努力,包括在一个项目(记住,我反正做网络测试,所以在很多情况下,单元测试将覆盖code,网页测试已经覆盖)。


  2. 可以解释与concete例子详细说明您的原因是什么?我经常看见的响应,如那不是它的意思为或它促进了更高质量的 - 这真的没有解决实际的问题,我必须面对,这一点,我怎么能证明 - 用实实在在的成果 - 花更多的一次测试?



解决方案

"Hit" does not mean "Testing"

The problem with only doing web-testing is that it only ensures that you hit the code, and that it appears to be correct at a high-level.

Just because you loaded the page, and it didn't crash, doesn't mean that it actually works correctly. Here are some things I've encountered where 'web tests' covered 100% of the code, yet completely missed some very serious bugs which unit testing would not have.

  1. The page loaded correctly from a cache, but the actual database was broken
  2. The page loaded every item from the database, but only displayed the first one - it appeared to be fine even though it failed completely in production because it took too long
  3. The page displayed a valid-looking number, which was actually wrong, but it wasn't picked up because 1000000 is easy to mistake for 100000
  4. The page displayed a valid number by coincidence - 10x50 is the same as 25x20, but one is WRONG
  5. The page was supposed to add a log entry to the database, but that's not visible to the user so it wasn't seen.
  6. Authentication was bypassed to make the web-tests actually work, so we missed a glaring bug in the authentication code.

It is easy to come up with hundreds more examples of things like this.

You need both unit tests to make sure that your code actually does what it is supposed to do at a low level, and then functional/integration (which you're calling web) tests on top of those, to prove that it actually works when all those small unit-tested-pieces are chained together.

这篇关于我为什么要这两个单元测试,通过(而不仅仅是网络测试)Web测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 00:05