Observations on Test-Driving User Interfaces 43
Test driving user interface development has always been a challenge. Recently, I’ve worked with two projects where most of the work has been on the user-interface components.
The first project is using Adobe Flex to create a rich interface. The team decided to adopt FunFX for acceptance testing. You write your tests in Ruby, typically using Test::Unit or RSpec.
FunFX places some constraints on your Flex application. You have to define the GUI objects in MXML, the XML-based file format for Flex applications, rather than ActionScript, and you need to add ids to all elements you want to reference.[1]
These are reasonable constraints and the first constraint promotes better quality, in fact. The MXML format is more succinct (despite the XML “noise”) and declarative than ActionScript code. This is almost always true of UI code in most languages (with notable exceptions…). Declarative vs. imperative code tends to improve quality because less code means fewer bugs, less to maintain, and it frees the implementor of the declarative “language” to pick the best implementation strategies, optimizations, etc. This characteristic is typical of Functional Languages and well-designed Domain Specific Languages, as well.
I don’t think you can underestimate the benefit of writing less code. I see too many teams whose problems would diminish considerably if they just got rid of duplication and learned to be concise.
The second project is a wiki-based application written in Java. To make deployment as simple as possible, the implementors avoided the Servlet API (no need to install Tomcat, etc.) and rolled their own web server and page rendering components. (I’m not sure I would have made these decisions myself, but I don’t think they are bad, either…)
The rendering components are object-oriented and use a number of design patterns, such as page factories with builder objects that reflect the “widgets” in the UI, HTML tags, etc. This approach makes the UI very testable with JUnit and FitNesse. In fact, the development process was a model of test-driven development.
However, the final result is flawed! It is much too difficult to change the look and feel of the application, which is essential for most UI’s, especially web UI’s. The project made the wrong tradeoffs; the design choices met the requirements of TDD very well, but they made maintenance and enhancement expensive and tedious. The application is now several years old and it has become dated, because of the expense of “refreshing” the look and feel.
What should have been done? These days, most dynamic web UI’s are built with templating engines, of which there are many in the most common programming languages. Pages defined in a templating engine are very declarative, except for the special tags where behavior is inserted. The pages are easy to change. It is mostly obvious where a particular visual element is generated, since most of the “tags” in the template look exactly like the tags in the rendered page. “Declarative” templates, like good DSL’s, can be read, understood, and even edited by the stakeholders, in this case the graphical designers.
But how do you test these page templates? When test-driving UI’s it is important to decide what to test and what not to test. The general rule for TDD is to test anything that can break. The corollary, especially relevant for UI’s, is don’t test anything when you don’t care if it changes.
It is usually the dynamic behavior of the UI that can break and should be tested. Templating engines provide special tags for inserting dynamic behavior in the underlying language (Java, Ruby, etc.). This is what you should test. It is usually best to keep the scripts in these tags as small as possible; the scripts just delegate to code, which can be test-driven in the usual way.
I see too many UI tests that compare long strings of HTML. These tests break whenever someone makes a minor look and feel or other inconsequential change. Part of the art of UI TDD is knowing how to test just what can break and nothing more. In the second project, incidental changes to the UI break tests that should be agnostic to such changes.
To conclude, keep your UI’s as declarative as you can. Only test the “declarations” (e.g., templates) in areas where they might break, meaning if it changes, it’s a bug. You’ll get the full benefits of TDD and the freedom to change the UI easily and frequently, as needed.
1 Disclaimer: my information on FunFX is second hand, so I might not have the details exactly correct; see the FunFX documentation for details.
To the second project:
Dean, maybe you should read…
http://blog.objectmentor.com/articles/2008/06/24/so-you-want-your-code-to-be-maintainable
In my experience, the desire of having made the right decisions upfront is mostly academic. From what I read, I don’t see too much trouble in making the code more flexible in terms of look and feel as you have tests around (that’s luxury these days ;-) ). The software seems to lack separation of concerns at architectural level.
Maybe, you can separate the server part from the content part as well as the content generation from the rendering part. E.g. by having the widgets generate a DSL (XML, YAML, custom external DSL) and separate the rendering.
To the UI-Tests: You are right. Making tests independend of changes in look and feel makes them less fragile and thus more valuable, see:
http://www.amazon.com/Why-Programs-Fail-Systematic-Debugging/dp/1558608664
Welcome to Freshstyleshop, the hottest urban clothing site on the net! We offer great products from Gucci sneakers, prada sneakers, LV shoes, True Religion Jeans and many more! Our selection of products are always increasing for the fact that we have new items added weekly to our selection. All products on our site are already marked down 40-60% off retail price. Freshstyleshop also backs all its orders with a 110% satisfaction guarantee, making sure that our customers are left satisfied with the hottest products on the net.
Test driving user interface is one of the challenge in programming especially with test driving web based services where browsers and protocols can cause different behaviors and cause some automated test code to go haywire.
good post ah ah
Well , the view of the passage is totally correct gucci mens ,your details is really reasonable gucci belt for men and you guy give us valuable informative post, size11 gucci sneakers I totally agree the standpoint of upstairs. I often discount gucci jeans surfing on this forum classic gucci wallets when I m free and I find there are so much good information we can learn in this forum!
I have been reading your blog last couple of weeks and enjoy every bit. Thanks.
let you have a lot in common,thanks for posting
CHM en PDF Convertisseur est un logiciel qui convertit des fichiers CHM (Compiled HTML Help Files) en format PDF avec le titre, le temps, la table des matières, en-tête, pied de page, numéro de page, etc. CHM en PDF Convertisseur possède encore plusieurs fonctions, par exemple :ajouter des filigranes, adjuster la résolution ou la taille du fichier, protéger les documents PDF par mot de passe, etc. Télécharger gratuitement CHM en PDF Convertisseur et expérimenter ce logiciel.
Awesome article!Thanks for ur nice sharing..
Backup iPhone SmS to computer
Moncler is the renowned high-end outerwear Discount Moncler brand which created a quilted jacket trend in the fashion world. Never one to stand still in time,It has always kept abreast of the latest Moncler Jackets technologies and stayed true to its origins without compromising its Moncler runway worthy style. If it has a Moncler tag, it will keep you warm on top of the highest mountain and be Moncler Men’s trendy on any city street.Features the latest selection of the north face clothing. You will enjoy what you Moncler Women’s show you. As well we offer you the good shopping experience with cheap and discount price.
Hermes Birkin Handbags are fashion icons regarded Hermes Handbags as much more than simple purses. They are status symbols, with waitlists forcing fashion fans to wait more than Hermes Birkin two years to own one.Hermes Birkin Handbags were created by Hermes head Jean Louis Dumas and actress Jane Birkin. Word is that Jean wanted a functional weekend bag, and so the Birkin was born. Now these Hermes Belts prestigious bags are seen on the arms of all the hottest celebs including Hermes Purses Victoria Beckham, Sarah Jessica Parker, and Oprah Winfrey.
Herve Leger Bandage High Waist Mini Skirts It is very eye-catching. You can wear Discount Herve Leger it in your casual time,go to office, go shopping, as you like in every place. As we know ,Herve Leger Dresses comes from French ,and found in 1985,it is the most famous designer house ,it always go in for the women’s beautiful shaped 90% Rayon, 9% Nylon,1% Spandex Zipper Herve Leger Dresses closure please just follow the show on the label to maintain the beauty Dry clean only These designer Herve Leger Bandage Dress and Herve Leger Skirts are feminine and sensual,stand out.
There is a brand that continues to turn out the Hermes Birkin seasons to seasons, yes, there is Hermes Handbags. In this season, there is bright colors. The hermes birkin replica,Birkin HandBags,hermes birkin purses are all in our warehouse.The Replica Hermes Birkin makes an effort to please the all Hermes 35CM Birkin Bags request by the masses. When you first come across with the Replica Hermes Belts the showroom, you instantly think that it is a Replica Hermes Birkin you would love to tote.
Beginning as a professional Cheap Moncler Coats seller, We achieved great success in this field. Moncler Giubbotti have a pretty good team who have been devoting themselves into reducing the costs by constantly Moncler Uomo looking for a best and steadiest manufacturer.By the year 2006, we had expanded our line from Moncler Gilet Donna to a wider range, They are Moncler Outlet,Moncler Boots,Moncler Scarf,Moncler Giubbotto Uomo. From Outletmoncler.com,People all over the world enjoy buying stuff and give high praises.
To have the Hermes birkin bag is becoming every woman’s dream.Though they have a hilarious collections of Replica hermes birkin,and others feminine accessories,but only few women are able to obtain it,because Cheap hermes handbags of the price,Since that it designed by the would’s most known designer,then the price reaches more ther hundreds Hermes Belts dollars for an item. If you are in such problem,loving the handbags,but have limited fund that Hermes Purses are far away from it’s price,then Replica Hermes Bags would your best solution.
give you the method to move songs, video and so on backup to Mac from iPhone.
Hey ,boys and girls,nice to talk with you if you can see my message,and also it’s our fate to share my idea with you.what do you think of it?
http://www.belstaffdiscount.com/belstaff-bag-s Hey ,boys and girls,nice to talk with you if you can see my message,and also it’s our fate to share my idea with you.what do you think of it?
Hey ,boys and girls,nice to talk with you if you can see my message,and also it’s our fate to share my idea with you.what do you think of it?
can be worn with any outfit, be that a glamorous and sexy skirt, a business suit or a casual pair of jeans Any shoe store collection display whether online or otherwise will not be complete without offering their brand This is quite
Awesome article!Thanks for ur nice sharing..accounting services
This article is very usefull for me! I can see that you are putting a lots of efforts into your blog. I will keep watching in your blog, thanks.
I found it very interesting and enjoyed reading all of it…keep it up, lovely job..Thank you for posting the great content.I was looking for something like this.I found it quiet interesting, hopefully you will keep posting such blogs..Keep sharing
Making tests independend of changes in look and feel makes them less fragile and thus more valuable
The pages are easy to change. It is mostly obvious where a particular visual element is generated, since most of the “tags” in the template look exactly like the tags in the rendered page.
V
very useful information for me! I’ll come here everyday
User interface is really important… it will be easy for us to see how its look ;)
give you the method to move songs, video and so on backup to Mac from iPhone. nice tips.
yes it is true
internette görüntülü olarak okey oyunu oyna, gerçek kisilerle tanis, turnuva heyecanini yasa.
Nice observations
user interface is very important feature to make things and website alive and easy to use..
building rich interfaces which are supported by lighter code is good practice, no more sluggish flash stuff
Slewing bearing called slewing ring bearings, is a comprehensive load to bear a large bearing, can bear large axial, radial load and overturning moment.
Seems great! Thanks. Observations of interfaces are very good.
thanks a lot for sharing. great stuff as always!
you go to bed
Tissot Classic Dream Watch will be a happy life style. Do not hesitate to choose tissot ladies watches and tissot gents watches to add your charming and beauty everytime.
well. your article is very useful for all the programmer and it can help me have a better code.
Test driven development is one of the central techniques in Extreme Programming.. and Test-driven development of GUIs is currently very difficult… Test Driven Development is a software development technique in which programmers writing failed test that will define the functionality before writing the actual code… medical billing georgia
Your article is extremely impressive. I never considered that it was feasible to accomplish something like that until after I looked over your post . Please visit our website for more information .
Persol Sunglasses come in a variety of styles and ray ban rb4105 colors to give you the look that you desire. The ray ban club master flawless finish and excellent craftsmanship are sunglasses what make people across the globe crave Persol Sunglasses.