PHP in Action

Paparrazzi testing

dagfinn | 09 October, 2007 02:15

Uncle Bob (Robert C. Martin) has blogged about testing GUIs (web interfaces, that is; JSP and Rails) without having to run a web server. I don't think it answers all the challenges I'm up against currently, but it inspired me to some heavy thinking about the essential issue of complete and not too cumbersome test covrerage

My conclusion so far is that Uncle Bob's articles is an example of what we may call the paparazzi principle.

Paparazzi try get as close as possible to celebrities they prey upon. The fewer walls or windows between the camera and the victim, the better. Pictures should be as revealing as possible; naked is or half-naked is good.

The paparrazzi principle for web testing is this: run the test from “above” as close as possible to the component you want to test. Inject mock objects from “below” as close as possible to the component you want to test. Even in ordinary unit testing, this can be far from trivial. Where the web interface itself is involved, it is much harder.

It follows that you don't want to use a real web browser or web server unless you must. It also follows that a realtively simplistic web client (SimpleTest's web browser is a good example) without a user interface is preferable to a web browser for human use. Unless you absolutely need it, that is. Therefore, Selenium is probably a step in the wrong direction. I want test tools that enable me to test user interaction without having to fire up these voluminous masses of software.

Comments

Problem

Tobias Struckmeier | 09/10/2007, 02:56

When you dont test in a real browser, you dont get the browser specific and JavaScript errors. Therefore starting a real browser makes sense. And how do you create the tests then? I like that recording approach of selenium.

Re: Paparrazzi testing

Rob... | 09/10/2007, 04:54

You've hit the nail on the head with Selenium. It is soooo slow!

I agree

Santosj | 09/10/2007, 06:43

I came to the same conclusion based on the requirements for acceptance testing of a web application. The choice of Selenium, while I still plan on writing code that uses it, adds more complexity to running the tests, than SimpleTest web browser. When all you need to know is that Field A and/or ID B exists, you don't need to run that through a real browser. A normal user can do that just fine. A normal user will tell you exactly what went wrong in their browser and their version.

JavaScript and Selenium

dagfinn | 09/10/2007, 23:15

First: the spam filter managed to mark all of the three real comments as spam. I'll have to watch it more carefully. About JavaScript and Selenium: If you have to test everything together and you have a lot of JavaScript, you do need something like Selenium -- or manual testing. But it's a good idea in any case to test the JavaScript in isolation. I've tested JavaScript from the command line using Ecmaunit. But I still haven't found a way to get a DOM implementation working from those tests.
 
Accessible and Valid XHTML 1.0 Strict and CSS
Powered by LifeType - Design by BalearWeb