TrainingConferencesAbout UsContact UsAdvertiseSQE.comRSS Feed

StickyMinds.com: brain food for building better software

Log In
 Clarify Your Search Criteria

Tips on Using Our Search Feature(s)
 
StickyMinds.com Home
ResourcesTopicsCommunityPowerPass
Home  >  Detail: Automated Testability Tips



A StickyMinds.com Original
Article Picture
Automated Testability Tips

By Linda Hayes

Send This Content to a FriendGet a Short Link to This ContentPrint This ContentSee User Comments About This Content

Summary: Imagine a world where applications are written with automated testing in mind. Fantasy? Before you dismiss the idea, read this week’s column. Linda Hayes makes some simple suggestions for designing for testability, including using unique names and adhering to class consistency.


HP
You would think that as automated testing tools gain market acceptance that application developers would become more aware of testability requirements. You would be wrong. 
 
The biggest culprit is the Web. HTML-based applications rely on dynamic content that rarely uses anything approaching a useful naming or other identification scheme for either pages or objects. But client/server systems are not immune, either. Just recently I saw one that used dynamic sub-windows that were completely name-free. The developers were proud of the fact that they were able to reuse the same window over and over, changing the contents on the fly. Well, since when did windows become a scarce resource, needing to be conserved? 
 
The irony is that the more dynamic the application, the greater the need to test and the higher the potential number of scenarios needing to be tested, both of which cry out for automation. Yet I can’t begin to estimate the amount of heartache and frustration—not to mention scarce time and money—that has been wasted struggling with the after effects of applications that were written without any concept of automated testability. 
 
If you are lucky enough to have a development group that is amenable to constructive suggestions, here is a guideline for improving automated testability. 
 
Sticks and Stones 
The old saying was wrong. Names can hurt you—especially names that are not unique, meaningful, or persistent.  
 
Each and every screen, window, or page (I’ll call them “displays” collectively to save space) within an application should have a name that is unique in the sense that it is not reused by other displays; meaningful in the sense that it is descriptive enough to be recognizable; and persistent from one build or release to the next.  
 
But even that is not enough. A display should be defined as a known collection of objects. This means that if the objects change—for example, fields or buttons appear or disappear based on data contents or user responses—then that is a new and different display. A so-called page or window that can completely change its contents and appearance depending on a laundry list of factors is not a page at all, it is a house of horrors. How can your automated test scripts ever verify where they are if the name of the display doesn’t tell you what it contains? 
 
As for objects, the same rule applies. An object’s name should be unique, at least within the context of the display, and it should also be meaningful. It must definitely be persistent; it cannot morph from Text1 to Text2 from one build to the next, or—heaven forbid—from one instance of the same so-called page to the next within the same session.  
 
The reason for these rules is simple. For an automated test to work at all, it must be able to recognize the application components. And to be able to work from one build or release to another, it has to be able to recognize those same components again.  
 
Class Will Tell 
Another requirement for testability is consistency, and here I am referring specifically to object classes, methods, and properties. The class library for an application should be well defined, which means not allowing developers to sneak in their favorite class just because they used it before, or having three different classes for the same type of control. And, for each class, the methods and properties should be used consistently. Names should be unique but other properties should not be, and methods should be exposed and available.  
 
For example, how many ways are there to implement a combobox? I have seen at least four: 1) allows you to type in the selection or select it; 2) allows selections only, no input; 3) moves the selection list to the item based on the letters being typed, moving around the list for each letter; and 4) selects the items closest to the typed input. I’m sure there are others, but the point is…why do we need them all? It just makes your test scripts long and complicated, and most likely will keep your end users off balance. 
 
Along the same lines, methods and properties should be made available, not private or hidden. Many a time have we wrestled with grids that did not expose the basic methods needed to get or set the contents of a cell. What’s the big secret, anyway? 
 
The reason for class consistency is that test tools rely on the object class, methods, and properties to interact with the application components. Inconsistency causes complexity, and disagreeable objects that won’t share their contents make it difficult, in some cases impossible, to automate at all. 
 
Now you might think these suggestions are pretty simple and obvious, and the truth is that they are simple, but based on the current state of application development, they must not be obvious. 
 
Wishful Thinking 
But what if applications were actually written to enable automated testability? What if each application had an interface that allowed a test tool—or any other language, for that matter—to enumerate the active display and all of its objects? What if the test could request an object by name, and could access all the methods needed to set or verify any of the properties exposed to the user interface? 
 
Gee, if that happened, what would all of the automation scripters do? Probably get the application tested on time and within budget.


About the Author
Linda Hayes is the founder of three software companies including AutoTester in 1986, which delivered the first automated testing program for the IBM PC. Linda has pioneered automated test tools. Her new company, Worksoft, offers Certify, which represents the next generation of enterprise-level test automation. Worksoft also offers a free online newsletter called "Reality Check," which provides links to articles, white papers, and other compelling information on testing. A frequent industry speaker and award winning author, she publishes the monthly Quality Quest column for Datamation, wrote the Automated Testing Handbook, and co-edited Dare to be Excellent with Alka Jarvis on best practices in the software industry. You can contact Linda at Linda@worksoft.com.

Back to Top
 

StickyMinds.com Weekly Column From 11/11/02 

Member Comments
Add Your CommentExpand Comments
 
Comment:    
by Teemu Vesala 1/1/2005

Let's go to the problem of private methods and fields (called "methods" later). This far I've worked as software developer, but I (at my own will) have jumped to testing wagon. Design for testability does not require to put methods non-private. In C++ you've got 'friend' -operator which lets private parts to be visible for testing classes. Unfortunately the coding standards of companies seems to miss this and lack of common testing framework makes things worse. Even at Java it's really simple to give test classess access to private parts of the class. It requires a bit more than C++, but it's still possible (I've got short text in...Read On

 
 
Comment:    
by Torsten Zelger 3/4/2003

That's all very nice but what are you doing if the developer uses a code obfuscation tool that makes all the nice naming conventions unusable such as in a JavaApplet-Under-Test? Do you tell the coder to hand-out two different kinds of applications. One for delivery and the other for testing?

 
 
Comment:    
by David Krauss 12/8/2002

It's amazing how easy it is to identify poorly architected UI's when you attempt to automate testing for them. Your points about dynamic windows, those that have one title, but many different 'views' are a nightmare to program against. I'm working with a Delphi application that is not exposing any properties, so this is truly black box testing. Developers can definitely increase the stability and simplicity of scripts written with third-party GUI testing tools by carefully exposing properties and methods that do not affect the integrity of the application. Mr. Rayboulds comments are correct regarding restricted access. However, additional...Read On

 
 
Comment:    
by Nancy Idaka 11/28/2002

Thanks for a timely article. Those of us involved with automated QA for my software company have been presenting these ideas to the chief architects of a new GUI project. It's good to see that we're not the only ones asking for this.

 
 
Comment:    
by Prasad B.S.V. 11/18/2002

Thanks for an excellent article. With the advent of OOP languages like Java testability has become a very big issue both at the unit & integration testing levels, but your article points out how it is a problem for functional testing as well! Because of incorrectly & inconsistently defined classes, auto testers are stuck with comboboxes that don't let consistent selection, scrollbars whose IDs change dynamically or nameless windows which can't be identified at all by the test tool. What is the solution to this problem? I think good V&V is the key. Good verification by a Tech QA Group should identify most such bad design issues early in...Read On

 
 
Comment:    
by Andrew Raybould 11/15/2002

Good developers do understand the value of testing, and automated regression testing in particular. Take a look at http://junit.sourceforge.net/doc/testinfected/testing.htm

FYI, restricted access (encapsulation) is a very important and longstanding concept in software engineering, providing protection against accidental violations of the interface/implementation boundary, which in turn protects the integrity of the design and reduces the ways in which a system could be put in an invalid state. It might be used inappropriately in some cases, but you can't make that argument until you understand what it is for.

 
 
Comment:    
by Bret Pettichord 11/13/2002

These are definitely problems for many projects. I have two ideas for how to get them addressed more systematically. First, i'd like to see technical handbooks by the test tool vendors on "how to make your application work with our tool." This column is just a general overview: developers need to know exactly what the rules are, which vary from tool to tool. Secondly, i'd like to see test tools priced so that they regularly appear on developer's desktops. This would give them a chance to experiment for themselves and see the consequences of how they are writing the code. As it is, they don't get feedback until the build is passed to the...Read On

 
 
Comment:    
by S L Mericle 11/13/2002

Although I think there are some good points here, there are some points that I would argue. For example, the author questions why 4 types of combo boxes are needed. It is quite possible that 4 are not needed. It is also quite possible the 4 ARE needed, depending on the context in which they are used. The important point is that the finished product should be easiest and most convenient for the USER - NOT for the tester or the developer. Another point is that there are very good reasons in software design to restrict access to various methods. This is one of the basic premises of object oriented programming. The methods are not "a...Read On

Author's Response:
11/13/2002    
ALthough I agree that it is the user and not the tester that is most important, consistency benefits both. And, of course, an application that has been thoroughly tested is ultimately for the end user's benefit. That being said, I'm sure there are reasons (although I haven't heard them) for restricting method access. I'd be interested in learning, though!

 
 
Comment:    
by Rajesh Sharma 11/13/2002

Tips are very Useful, Linda has really put it nicely, Now its left with the developers to count on this next time atleast. Articles like these ...makes us feel good about our findings. Thanks Linda for the findings and sharing them here.

Author's Response:
11/13/2002    
Thanks, Rajesh. But don't count on the developers to take notice unless you escalate these issues, and do it early enough in the development cycle.

 
 
Comment:    
by edA-qa mort-ora-y 11/13/2002

I generally see the use in going this diretion of commonly exposing the interface to the application: for the most part it helps a lot in testing. There is always a potential pitfall, and I've seen this before: often the exposed interface is tested rather than the genuine user interface. This directly leads to a loss of coverage of the entire area between the user and the exposed interface you are testing.

Author's Response:
11/13/2002    
Good point. However, I look at automation as an adjunct to manual testing. Automated can be used to exercise the application over many pathways and scenarios, then manual testing added to give users exposure to the true interface for destructive and usability testing.

 
 
Comment:    
by LaBron Thompson 11/12/2002

Excellent article. Simple suggestions, but very true. I have run into the same issue time and time again in working with cross browser compliance issues with a web-app I'm charged with automating regression scripts for and the nameless objects have always been a frustration. I just hope some developers will take note.

Author's Response:
11/13/2002    
Thanks, LaBron....but I would bet they won't take note unless you raise the issue, and do it early!

 
 
Comment:    
by Michael O’Connor 11/12/2002

I've asked vendor after vendor to explain the development "rules" that support automated testing tools. They never knew. thank you, thank you, thank you - a very practical, useful article.

Author's Response:
11/13/2002    
You're welcome, you're welcome, you're welcome!

 
 
Comment:    
by Srinivasan Desikan 11/11/2002

I am happy to see an article on Automation after a longtime at stickyminds. Well written one. It is important to have a common understanding in the team that we should go for automation and products inturn developed for automation. Some of the product code also can be reused for automation. Instead of looking only time/cost saved becuase of automation, we should start thinking about test coverage using automation. Automation for GUI normally fails due to frequent changes in the GUI. If we do proper prior analysis and reduce changes to GUI and also develop automation scripts assuming changes will be part of life, the suggestions given by...Read On

Author's Response:
11/13/2002    
Thanks, Srinivasan, and hallelujah for pointing out that automation is about increasing coverage, not saving time or money.

 
 
Comment:    
by Sharad Kamath 11/11/2002

Great article. Please post more like these. - Sharad

Author's Response:
11/13/2002    
Thanks, Sharad. I hope it helps.

 
Back to Top


Marketplace

Web based bug tracking - AdminiTrack.com
AdminiTrack offers an effective web-based bug tracking system designed for professional software development teams.

Census: Web-based Bug Tracking and Defect Tracking
Track software bugs, defects, enhancements, support calls, and more. Issue tracking software that is scaleable, fully customizable and integrated with VSS. Includes e-mail notifications, role-based workflow, change history, and Crystal reporting.

“Six Sigma” Certified?
100% Online-Six Sigma Certificate From Villanova -Find Out More Now.

Test cases to go
20 test factors with 10 values each -- 181 all-pairs test cases in 7 seconds.

BugMonitor.com - We make your software better!
Hosted, bug tracking/issue management service throughout your development life cycle. FREE trial.

Get your product or service listed here.
Subscribe to Better Software Magazine
Subscribe to Better Software Magazine

First Name:

Last Name:

Email Address:


Home   |   Resources   |   Topics   |   Community   |   PowerPass



© 2008 StickyMinds.com. All rights reserved.
StickyMinds.com is a division of Software Quality Engineering.
Privacy Policy    Terms & Conditions    Link to StickyMinds.com    Feedback


MKS, Inc.

Borland



STAREAST 2009