网站中每个链接的测试用例?
我有一个关于网站开发领域的测试用例的非常基本的问题。 为站点中所有页面的每个超链接设置单独的测试用例是否有意义? 例如,我的网站可能有 10 个页面,每个页面大约有 10 个页面。 其中有 10 个超链接。 我是否应该有 100 个测试用例,每个测试用例都解释该链接应将我重定向到哪里。 我只是想知道在上线之前确保所有链接正确的最佳方法是什么。
I have a pretty basic question about test cases in the world of Website development. Does it make sense to have a separate test case for each hyperlink for all pages in a site? For e.g. my site might have 10 pages, each with approx. 10 hyperlinks in it. Should I have 100 test cases each explaining where that link should redirect me to. I just want to know what is the best approach to make sure all links are correct before going live.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
中间立场的做法是抓取网站并确保所有链接返回 200/300 状态(也就是说不是 404 或 500)。
您甚至可以扩展它来编写正则表达式来定义哪些应该返回重定向,哪些应该直接返回 200。
Something that's kind of a middle ground, would be to spider the site and make sure that all of the links return 200/300 statuses (that is to say not 404s or 500s).
You could even extend it to write regexes to define which should return redirects and which should straight up return 200s.
如果这些链接没有太大变化,您可以考虑使用一些简单的测试:它们是否仍然指向某个页面? 该页面位于同一服务器上吗? 它是一个 html 页面吗? 是 https 链接吗? 等等。而且,正如科格西所说,你可以认真测试最重要的一个。
If these links do not change much, you could consider using some simple tests : do they still point to a page ? is that page on the same server ? is it an html page ? is it an https link ? etc. And, as Cogsy said, you may test seriously the most importants one.
您可以将其放在私人服务器上并使用 wget 来测试损坏的链接。 GNU Wget 手册页 将是一个很好的起点。 recursive 选项和spider 选项似乎是最常用的。 如果您只想报告您的域名,请查看-D选项。
如果您编写了一个快速的 bash 脚本,那么您将来也可以使用它。
这显然是简单快捷的选择。
You could put it live on a private server and use wget to test for broken links. GNU Wget manual page would be a good place to start. The recursive option and the spider option seem to be the most used. If you only want to report your domain look at the -D option.
If you write a quick bash script you'll have it around for the future as well.
This is obviously the easy and quick option.
“测试直到恐惧变成无聊”
真的取决于你对每个环节的担心程度......
"Test until fear turns to boredom"
Really depends on how worried you are about each link...
嗯 - 作为常识,如果你想确保它们工作,你必须以某种方式对它们进行冒烟测试 - 但我强烈建议你为此设置某种自动化 UI 测试套件。
测试用例通常是在功能上定义的,因此将测试用例仅与代表功能的超链接(在您的情况下)相关联是有意义的,如果它们只是重定向,您最终会得到一堆高度隆重的文档,这些文档将很快就会被灰尘覆盖。
Well - as a matter of common sense, if you wanna be sure they work you're gonna have to smoke test them somehow - but I highly suggest you to setup some kind of automated UI testing suite for that.
Test Cases are usually defined on features, so it makes sense to associate Test Cases only to the hyper links (in your case) that represent features, if they're just redirections you'll just end up with bunch of highly ceremonious docs which will be covered in dust soon enough.