开发者

Methods to (unit) test the interface of a website

I'm wondering what are the best practices to test the "interface functionality" of a website.

I'm interested in what methods are available for testing the interface and dynamic generated contents. In particolar I struggle to figure out whether it is possible to create automated tests for actions that require user interaction, or if it is just a waste of time and I should开发者_开发知识库 just get some beta tester do this type of work.

I'll try to give some examples:

  1. on SO when you type the title of your new question some "related questions" appear. Obviously you can implement some sort of test that tells you that you got the correct number of related questions, and that they get displayed, but how do you test the "correctness" of the links? Would you setup a mock set of questions (always the same) and check that the returned questions are some pre-established ones? That would work, sure, but it's hardly testing the robustness of your search algorithm. What happens when other questions are added to the pool? Are the returned results still "related"?

  2. Clicking on a certain button a JS is called that generates a "popup div", that the user can move around. Again, how do you automatically test this kind of interface? You can test for the appearance, but how do you test for the movement?

  3. You have an interface to upload files to the site to embed in your message (like the image icon here on SO). So the user is required to 1) press the button 2) browse for the file 3) wait for the upload 4) press OK and finally he/she will see the image in the message. Again, I can see how you can automate the test for the upload (e.g. try upload a "normal" file, then one which is too big, of an unsupported format and so on). But what about the use of the interface? If the OK or the Browse buttons don't work for whatever reason it's no use that the upload works as, at the end of the day, you still cannot upload your file and see it in your message.

Obviously all of the above are fairly straightforward to beta-test (just tell a bunch of users to test your website and they'll notice if anything goes wrong), but can you do (and more importantly would you spend time implementing) automated tests on this kind of things? Also, when beta testing, would you have testers "run wild" and do whatever they want on the site, or rather tell which functions you'd like them to test. I'd propend for the 1st but I'm open to suggestions.


What we use at our place is Selenium. It has a few quirks, but overall it has allowed us to increase test coverage enormously, with I think a few thousand new system tests clicking around. Note that one can argue if this is really "unit" testing. That depends on your stack, I guess. We have to have our system running for this, so it's more integration testing.

For pure unit testing of JS we use QUnit, and HTMLUnit has proven somewhat popular as well, for "middle of the road" tests that don't use a real browser but still gives you a DOM and whatnot.


Some of you problems may be answered by visual testing, and there is a great framework for it: http://sikuli.csail.mit.edu/

It allows you to expect visual results and programmatically control a web page.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜