如何测试应用程序?
在我看来,我一直在构建一个非常酷的 RIA。 但现在它已经接近完成,我需要对其进行测试,看看是否存在任何错误或违反直觉的部分或类似的东西。 但如何呢? 每当我请某人尝试打破它时,他们都会看它大约 3 分钟并说“它很坚固”。 你们如何测试东西? 我以前从未使用过单元测试,实际上大约 3 个月前我什至从未听说过单元测试,而且我仍然不太明白它是什么。 我是否必须构建一个全新的应用程序来运行每个功能? 这将花费很长时间,而且某些函数可能只会在某些情况下产生错误,所以我不理解单元测试。
I have been building IMO a really cool RIA. But its now close to completion and I need to test it to see if there are any bugs or counter-intuitive parts or anything like that. But how? Anytime I ask someone to try to break it, they look at it for like 3 minutes and say "it's solid". How do you guys test things? I have never used a UnitTest before, actually about 3 months ago I never even heard of a unit-test, and I still don't really understand what it is. Would I have to build a whole new application to run every function? That would take forever, plus some functions may only produce errors in certain situations, so I do not understand unit tests.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
这个问题是非常开放式的,所以这篇文章不会回答你所有的问题。 如果您可以完善您正在寻找的内容,那将会有所帮助。
您可能需要进行两项主要测试。 第一个是单元测试,第二个是所谓的验收测试。
单元测试是相对隔离地尝试每个类/方法并确保它们有效。 您可以使用 jUnit、nUnit 等作为框架来保存测试。 采用一种方法,看看它可能期望什么不同的输入以及它的结果是什么。 然后为每个输入/输出对编写一个测试用例。 这将告诉您大部分部件都按预期工作。
验收测试(或有时称为端到端测试)正在运行整个系统并确保其正常工作。 列出您希望用户执行的场景列表。 现在系统地尝试所有这些。 尝试它们的变体。 做他们的工作? 如果是这样,您可能已经准备好将其推广到至少有限的受众。
另外,请查看 James Whittaker 撰写的如何破坏软件。 这是最好的测试书籍之一,读起来很短。
The question is pretty open-ended so this post won't answer all your question. If you can refine what you are looking for, that would help.
There are two major pieces of testing you likely want to do. The first is unit testing and the second is what might be called acceptance testing.
Unit testing is trying each of the classes/methods in relative isolation and making sure they work. You can use something like jUnit, nUnit, etc. as a framework to hold your tests. Take a method and look at what the different inputs it might expect and what its outcome is. Then write a test case for each of these input/output pairs. This will tell you that most of the parts work as intended.
Acceptance testing (or end-to-end testing as it is sometimes called) is running the whole system and making sure it works. Come up with a list of scenarios you expect users to do. Now systematically try them all. Try variations of them. Do they work? If so, you are likely ready to roll it out to at least a limited audience.
Also, check out How to Break Software by James Whittaker. It's one of the better testing books and is a short read.
第一件事是系统地确保一切都按照您期望的方式进行。 然后,您想要针对每个实际的硬件以及可行且合适的软件安装组合进行尝试。 然后,您想要获取人类交互的每个点,并尝试放入尽可能多的数据、不放入数据以及可能导致异常的特殊数据。 尝试按照您意想不到的顺序或工作流程做事,有时某些操作取决于其他操作。 您和您的朋友自然会按顺序执行这些步骤,如果有人不按顺序执行这些步骤会怎样? 此外,让新手使用它是了解用户可能尝试的奇怪事情的好方法。
First thing is to systematically make sure everything works in the manner you expect it to. Then you want to try it against every realistic hardware with software installed combination that is feasible and appropriate. Then you want to take every point of human interaction and try putting as much data in, no data in, and special data that may cause exceptions. The try doing things in an order or workflow you did not expect sometimes certain actions depend on others. You and your friends will naturally do those steps in order, what happens when someone doesn't? Also, having complete novices use it is a good way to see odd things users might try.
发布测试版吗?
Release it in beta?
它基于 Xcode 和 Cocoa 开发,但此视频仍然是单元测试的精彩介绍。 单元测试实际上应该与开发一起完成,因此如果您的应用程序即将完成,则需要一段时间才能实现。
It's based on Xcode and Cocoa development, but this video is still a great introduction to unit testing. Unit testing is really something that should be done alongside development, so if your application is almost finished it's going to take a while to implement.
Firebug 为网络应用程序提供了一个很好的分析器。 至于测试 JS 文件,我使用 Scriptaculous。 无论您使用什么后端都需要经过全面测试。
但在此之前,您需要了解什么是单元测试。 单元测试是验证源代码的所有单独单元是否按预期运行。 这意味着您验证所有函数/方法的输出。 基本上,请阅读此。 除了单元测试之外,还有不同的测试策略,例如集成测试,即测试不同模块之间的集成。 你要求人们做的是验收测试,即验证它的外观和行为是否符合最初的计划。 这里详细介绍了各种测试策略。
PS:总是测试边界条件
Firebug has a good profiler for web apps. As for testing JS files, I use Scriptaculous. Whatever backend you are using needs to be fully tested too.
But before you do that, you need to understand what unit testing is. Unit testing is verifying that all of the individual units of source code function as they are intended. This means that you verify the output of all of your functions/methods. Basically, read this. There are different testing strategies beyond unit testing such as integration testing, which is testing that different modules integrate with one another. What you are asking people to do is Acceptance testing, which is verifying that it looks and behaves according to the original plan. Here is more on various testing strategies.
PS: always test boundary conditions