Sunday, October 5, 2008

Keyword driven framework

Keyword driven framework is one where (pre-defined) keywords are used to describe actions. These actions match up to a process, related to the application.

Or

Keyword-driven testing is an application-independent framework utilizing data tables and self-explanatory “keywords” to explain the actions to be performed on the AUT.

Keyword-driven testing splits the test procedure into logical components. These logical components are then used repeatedly in the assembly of new test scripts.

Below I have given 3 examples of Keyword Driven Automation Framework. These may not be complete in them, but are a sort of starter in order to give you a little feel so that you can start well on your own.

Example 1



WINDOWCOMPONENTACTIONEXPECTED VALUE
Yahoo Sign-in PageYahoo!ID boxVerifyValue"UserName"

Framework Pseudo-Code
Primary Record Processor Module:

Verify "Yahoo Sign-in Page" Exists. (Attempt recovery if not)
Set focus to "Yahoo Sign-in Page ".
Verify "Yahoo! ID box" Exists. (Attempt recovery if not)
Find "Type" of component "Yahoo! ID box". (It is a Textbox)
Call the module that processes ALL Textbox components.

Textbox Component Module:

Validate the action keyword "VerifyValue".
Call the Textbox.VerifyValue function.

Textbox.VerifyValue Function:

Get the text stored in the "Yahoo! ID box" Textbox.
Compare the retrieved text to "UserName".
Record our success or failure.



Example 2

Code:
LaunchYahoo! Mail
VerifyYahoo! Mail Login Screen
Login Username Password
VerifyWelcome Screen
Logout


Here, the keywords are Launch, Verify, Login, and Logout, but they could be any actions relevant to your testing context.

Example 3

Test1
LoginJohnAAA
VerifyScreenWelcomeScreen
Logoff
Test2
LoginSaraBBB
VerifyError“Wrong username.”
Test3
LoginTammyCCC
VerifyError“Unknown Error.”



Above, the first column commands are called keywords or action words.

Test driver reads the test file, searches for the library function associated with the keyword (Login) and then performs execution using remaining data on the row (“John,” “AAA”) as arguments to the function.


Advantages:

Spreadsheet can be used to write detailed test plan including all input and verification data.

"Generic" utility scripts created for testing an application can be reused to test another application.

Higher levels of maintainability and efficiency can be attained by using the same principles of functional decomposition (modularity) with Keyword driven framework and separation of script and data (data driving).

Another advantage of the keyword driven approach is that testers can develop tests without a functioning application as long as preliminary requirements or designs can be determined.

Disadvantages:

Scripting language proficiency is needed.

It may require longer implementation time.

Also See:

5 Generations of Test Automation

Functional Decomposition Framework

Choose Your Test Automation Framework