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
ResourcesTopicsCommunityPowerPassBlogs
Home  >  Detail: Keyword-Driven Testing


Viewing Item 1 of 480


A StickyMinds.com Original
Article Picture
Keyword-Driven Testing

By Danny R. Faught

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

Summary: A curious phenomenon occurring among testers has caught Danny Faught's attention; testers everywhere are independently writing their own keyword-driven testing scripts. But what is keyword-driven testing, and how does it work? Is it better than data-driven testing? In this week's column, Danny reveals the testing method's simple design that has made it popular with many testers and non-testers alike.


ThoughtWorks
I've noticed a curious phenomenon happening all over the place—testers are independently inventing keyword-driven testing. If so many testers are deciding it's a good idea, maybe it's worth a closer look. There are many other terms people have used to refer to the same general concept including "action words," "test frameworks," and "third-generation test automation." 
 
Here's an example of a keyword-driven test case:  
Action Fixture
startfitnesse.fixtures.CountFixture 
checkcounter0
presscount 
checkcounter1
presscount 
checkcounter2
entercounter5
presscount 
checkcounter6
from URL http://fitnesse.org/FitNesse.ActionFixture
 
This looks too simple to be an automated test script, but too terse to be a manual test script. What's up? 
 
How Keyword-Based Testing Works 
You can use a keyword-based test for manual testing, but the technique really shines for automation. The process begins with a test designer writing a test case -- like the one above. The test designer doesn't have to know how to program; he could be a business analyst. A programming-savvy toolsmith implements a framework that provides keywords like "start," "check," "press," and "enter." The framework might make use of a separate interface driver, such as a graphical user interface (GUI) test tool. 
 
The wonderful thing about test scripts at this level of abstraction is that they can be independent of both the interface driver and the application's interface. Though the sample script above uses terms suggesting a GUI interface, the interface could be an application program interface (API), web service, or anything else. It's best to avoid embedding any assumptions about the design of the user interface in the keyword script. The framework can use an API early in the project, then later change to go through a GUI without modifying the test script. Testers can also change interface drivers without changing the script as long as the keyword framework isn't built into an interface driver. 
 
Have We Evolved? 
You may have heard of "data-driven testing," that uses a script roughly equivalent to the implementation of a single keyword. Along with the script, testers develop a list of data values that are fed to repeated invocations of the script. The difference between data-driven and keyword-driven testing is that each line of data in a keyword script includes a keyword that tells the framework what to do with the test data on that line. 
 
Some keyword framework designers like to write test cases that use multiple keywords, as in the example above, so the script looks like a simple programming language. Others prefer to have a single keyword that can perform the work of an entire test case, blurring the line between data-driven and keyword-driven testing. 
 
After reading the literature about these two approaches, I got the notion that keyword-driven testing is a more evolved version of data-driven testing. But I noticed that FitNesse users usually choose data-driven testing using the "column fixture" rather than keyword-driven testing using the "action fixture" as used in the example above. So maybe it's not as simple as one being a better version of the other. Though it's rarely done, you can use both at the same time by iterating a set of data values through multiple runs of a multi-line keyword script. 
 
The Right Reasons 
If you're not a programmer, you can still write automated tests if your organization supports keyword-driven test automation. I've talked to some people who have used keyword-driven testing who say that it's not practical to expect non-technical staff to write keyword scripts, but others have said it works fine. The jury is still out on that point. Managers need to understand that the team still needs programmers dedicated to implementing and maintaining the framework. 
 
The real benefit is the improved maintainability of the test scripts. The keyword approach follows in a longstanding tradition of modularizing the test automation so that it's easier to recover from user interface changes in the system under test. That benefit alone is sufficient to justify keyword-driven testing, even if all of the test designers are expert programmers. 
 
Thanks to Mike Silverstein, Mike Kelly, and Carl Nagle for their early feedback on this article. 
 
Further reading 
  • "Keywords are the Key to Good Automation," presentation by Danny R. Faught. Includes a list of tools that support this technique, and additional synonyms and references.
  •  
  • FitNesse at http://fitnesse.org/
  •  
  • Just Enough Software Test Automation, Daniel J. Mosley and Bruce A. Posey, 2002
  •  
  • Integrated Test Design and Automation, Hans Buwalda, Dennis Janssen, Iris Pinkster, 2002


  • About the Author
    Danny R. Faught is a testing consultant, author, and trainer. Danny is the publisher of Open Testware Reviews and proprietor of Tejas Software Consulting based in Fort Worth, Texas. Visit tejasconsulting.com for more information.

    Back to Top
     
     

    Member Comments
    Add Your CommentExpand Comments
     
    Comment:    
    by Shrinivas Kulkarni 8/10/2008

    Hi Danny,

    How to perform testing (A process of technical investigation performed on be half of customers to reaveal quality related information about software product or a service - an act of questioning - open ended learning process) using keywords ...

    did you intend to say "Keyword driven automation" ...

    Why is this terminology mix up? why use testing and automation interchangeably?

    Shrini

    Author's Response:
    8/11/2008    
    Hi, Shrinivas. I think what you're saying is that you don't like the phrase "Keyword-Driven Testing." In the years since I wrote this article, I have been trying harder to avoid the generic term "testing" when I can be more specific. To use a keyword-driven approach for automated testing, toolsmiths build a keyword-based automation framework, test designers design keyword-based test cases, and test technicians execute the keyword-based test cases. Sometimes, keywords are used to design and execute manual test cases. Does any of that fit within your general definition of "testing"? Email me and let me know.

     
     
    Comment:    
    by Mike Whittaker 12/9/2004

    I believe I once developed a hybrid: keyword-driven data-driven testing. The application was a smartcard payment system, and I wanted to generate many different card content scenarios. I created a keyword-based data generator to allow me to easily created the necessary structures and variations in the card simulator I had built for testing the application. All I had to do then was to make template definitions for keywords at the beginning of the script, and then reuse them with different embedded data values later on. I even defined a copy/paste keyword mechanism to allow me to reuse sets of data without having to repeat it...Read On

     
     
    Comment:    
    by Bob Bhatti 12/8/2004

    Hi Danny, I have used keyword testing on a number of projects. However, I am curently working on a concept which I personally believe will enhance the use of keyword testing. The paper is still WIP, but when finished I will hopefully post it on this site for review. What I am working on is essentially the concept of embedded test cases. Basically you would have one template test case for a particular process (almost a unit test), this will use some default values (i.e. constants), however, the test case itself can be called from a functional/system test case, with any data overrides being provided (this will introduce variants). So...Read On

     
     
    Comment:    
    by Frits Bos 12/4/2004

    Danny, I think there is still some confusion about what is meant by data-driven testing vs. keyword-driven testing. I have done extensive work with data-driven testing, employing Certify as the physical execution engine. Certify actually incorporates both models: 1. It provides a library of predefined actions that you can invoke as keywords in context (the context being 3270, HTML or other types of interfaces). You can assign data values by reference so that a given script is generalized. A set of actions would constitute a keyword-driven script. 2. Because you can assign data values by reference it is easy to cycle through tables of...Read On

     
     
    Comment:    
    by Rommy Rempas 11/29/2004

    Danny, I got my first independent consulting engagement when I proposed the Keyword-Driven Testing approach. It was for a client who didn't believe in manual testing. However, for that project I still think using a manual tester would be a better choice.

     
     
    Comment:    
    by Erik Petersen 11/11/2004

    It is interesting that these approaches seem very similar to assembler or machine languages that sit below the programming languages that applications are written in. One major acceptance factor for getting business users involved is the use of spreadsheets to store the keywords. They are familiar with spreadsheets and are less intimidated, especially cos the magic that makes it work is hidden from them....

    Author's Response:
    11/11/2004    
    Yes, keywords scripts are at a higher level of abstraction, like a scripting language is a higher level than C code. And the fact that keyword scripts tend to be written in an environment that's familiar to the test developer is a key point. Spreadsheets are the most common, and I've also seen plain text files and of course, Wiki pages.

     
     
    Comment:    
    by Robin Knowlton 11/11/2004

    Danny, We're currently investigating these "next generation" test tools. At a minimum, we would like the test design and execution performed by our business analysts, while significantly reducing IT involvement. In addition, we have a multi-platform environment including 3270 emulation, web, and traditional client/server. We have looked into Worksoft's Certify and Mercury's Business Process Testing with QuickTestPro. Do you know of any pro's/con's with each? Thanks, Robin

    Author's Response:
    11/11/2004    
    Don't reassign those IT folks until you get a handle on how much effort is required to support the framework and maintain the keywords, and to help analyze test failures.

    For opinions on commercial tools, please contact me via email.


     
     
    Comment:    
    by John Daughety 11/10/2004

    One great strength of keyword-driven testing is the opportunity to provide granular feedback. For the "push button" action, for example, the programmer can insert several verifications, including checking for the appropriate window and control and logging a message if the action is successful. When an unattended test crashes in the middle such log messages can be a great debug tool. When I implemented this with SilkTest, I extended the standard window classes and created my own functions for each "keyword", such as "pushButton(window_name, control_name)". Within each custom function I could write my own log statements, verification and...Read On

    Author's Response:
    11/10/2004    
    Hi, John. I would think that the simple approach of developing a library of test functions could benefit from these kind of enhancements, too. But I still prefer to take that next step and develop the functions as keywords rather than as an API to call from a programming language.

     
     
    Comment:    
    by Sidney Snook 11/10/2004

    I have been using WebFT as an automated test tool and I am evolving from scripted test cases with high maintenance requirements to exploring table-driven,data-driven, and model-driven tests with hopefully lower test case maintenance requirements. Do you know enough about WebFT to give me an example of how an "ActionFixture" could be used with a tool such as WebFT. Also, does keyword-driven testing have the potential to provide test cases with a lower maintenance requirements than Model-driven, table-drive or data-driven test scripts

    Author's Response:
    11/10/2004    
    I'm not familiar with WebFT, but I can give a general answer. A keyword framework can sit on top of an interface driver like WebFT. That would mean either having a program that reads your keyword scripts and then generates test scripts in a language that WebFT understands, or developing your framework using WebFT's scripting language and dynamically interpreting the keyword scripts. There are a handful of exiting commercial and free tools that give that that keyword framework, so investigate that before you build your own (see my presentation linked above for a list). Most or all of them would need some work to integrate them with WebFT. "Fixture" is a term used more often in terms of unit testing than keyword-driven functional testing - it's an artifact of FitNesse's roots. They key elements you would be adding would be the framework that parses your scripts and hooks into your interface driver, the implementation of your keywords (some generic, some specific to your application under test), and your keyword scripts that implement the test cases.

    As for your last question, "table-driven" testing is a synonym for keyword-driven testing (the vendors have vigorously but so far unsuccessfully tried to explain to me how each of their approaches are radically different). Data driven testing seems to work well when you're varying your data but not the procedure used to feed the data to the application. Data-driven testing can be supported by a keyword framework. It's hard to compare model-driven testing with keyword-driven testing. I'm not as familiar with the model-driven approach, but I think a key difference is the fact that keyword-driven tests are still individually designed, while model-driven tests can crank out lots of tests once you get the model in place. It's difficult to get the model implemented in the first place, however, and it may be difficult to define your oracle that determines whether the tests pass.


     
    Back to Top



     
    Ads By Google
    What's This?
     
     



    Home   |   Resources   |   Topics   |   Community   |   PowerPass



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


    Cloud Connection

    Rally Software




    STAREAST 


    Better Software Conference