How to Use Keyword Driven Testing

Jul 21, 2022 | Best Practices, Test Automation Insights

Running tests on software can be a long and difficult process, especially if you have to manually write and run each test for each feature. If you’re hiring a testing engineer to handle the tests, you also need to make sure they understand the technology and programming language you’re using, which may limit your options for functional testers.

Keyword-driven testing can help you eliminate these challenges, splitting your test design, test development, and test execution stages into separate modules to make them more concise and readable. By categorizing each action as its own keyword, this testing framework lends itself to automation. You can then run a significant number of tests in a short time and minimize the possibility of human error.

Keep reading to learn more about the benefits of keyword-driven testing and how you can use it to improve your software testing process.

What Is Keyword-Driven Testing and Automation?

Keyword-driven testing is a functional automation testing method that uses data files to link specific keywords to the application you’re testing. Every test keyword describes the set of actions that the software needs to take to test a certain function. For example, if you test your application with the keyword “login,” it should run the necessary functions to log a user in.

This modular approach lets you test each function individually, making it easier to write tests abstractly. Novice and nontechnical testers also find this an easier testing framework to understand.

The three main components of a keyword-driven testing framework are:

  • Vocabulary, or the keywords and phrases
  • A compiler, which aggregates keywords and checks syntax, like an Excel spreadsheet
  • An automation core framework, which helps organize the design and implementation activities for your testing, making it easier to execute and report on tests

The initial work necessary to set up a keyword-driven testing framework can discourage people from trying it out. However, its design makes it extremely scalable and requires low maintenance in the long run, which makes it a valuable framework option to implement early.

How To Use a Keyword-Driven Testing Approach

Knowing how to test keywords requires an understanding of two basic stages: design and implementation.

As you will see in the steps below, a lot of the process is designing the framework — categorizing and defining keywords, compiling them into test cases, and building the driver scripts that will perform the tests. This makes it easy to run the tests in the implementation step, when you execute the commands.

1. Identify Low- and High-Level Keywords

The first step is breaking the application into functions, which you can categorize hierarchically as either low-level or high-level. Each function that describes a single-step action, like “click” and “double click,” is a low-level keyword. These are the building blocks that let your application perform more complex tasks.

High-level keywords describe these complex tasks that combine a number of low-level keyword functions. For example, if your app lets the user print a ticket, you could use “print ticket” as a high-level keyword.

2. Implement the Keywords

Keyword implementation is the process of connecting the keywords with their appropriate data values, like the sequence of operations necessary to perform the function it describes. You usually do this in a table, like an Excel sheet.

3. Create Test Cases

To create a test case, you need to list relevant keywords in what’s called an action table, along with the necessary data to run the test, such as a value to input and an object to act on. This table is generally in a common data format, like .CSV or .XLS. 

The easiest way to create tests is to record them as you use the application. That way, keyword testers don’t need to understand the application’s inner workings — they just need a plan for what functions they want to test. Once you’ve made the recording, you can always modify the test cases to suit your needs.

4. Create a Driver Script

A driver script executes a test using the test case information. You would normally have to create individual scripts for each test, but, since keyword testing is modular, you or your automation engineers can instead write reusable scripts that handle different sections of a test flow. The driver script then calls each part in the right order to run the test.

5. Execute Automation Test Scripts

To run your tests, you or your automation expert can now execute the driver script with any necessary parameters, also called keyword arguments. If you want to test batches of functions together, you can add some decision-making logic to your test. For example, if you had two tests — A and B — and test B is a function that is dependent on test A, you can tailor the automation so that test B only runs if test A succeeds.

You can generally use the Return operation to get a single result from your test, though your specific automation framework may have its own way to handle tests that yield multiple results.

If you want to modify any keyword tests and run them again, you can just change the parameters, not touching the driver scripts at all. This is why keyword-driven test automation is much easier to maintain than testing with scripts.

Benefits of Keyword-Driven Tests

Keyword-driven tests are a powerful modular tool that people without deep coding knowledge can find especially useful. Here are some of the best benefits of adopting keyword-driven testing.

1. Provide a More Functional Process for Testing

Since you build tests using a framework of keywords that each describe a specific function, keyword-driven testing is a more functional process that helps you write tests in a more abstract manner. This lets you test more realistic use cases.

Because of its modular structure, keyword-driven testing also lets you start automation early in the software development life cycle, before you’ve produced a complete stable build. Instead, you can create simple functional tests for each feature as early as possible, when it’s much easier and cheaper to debug any errors.

2. Develop Tests Without Knowledge of Programming

Tests that only rely on scripting require testers who understand the scripting language. However, keyword-driven testers can write their test cases based on the keywords. This means they need no formal programming knowledge, just an understanding of how the app should work, unlike other popular approaches like data-driven testing.

This also introduces another way to develop tests — by recording them. If the testing engineer plans out their tests, they can record them on the app and then modify parameters in the action table to suit their goals. This further separates the tester from the code, letting them focus fully on running their functional tests instead of writing testing scripts. Newer testers can also be productive sooner, since they don’t have to learn as much technical information.

As an added benefit, this also makes test cases easier for all stakeholders to read and understand, helping them understand the app better.

3. Implement With Any Automation Tools Available

Because keyword-driven testing simply combines keywords and test data, you can easily implement most of your framework with any automation tool. You may still need to modify some code, but a significant portion — the test cases — can remain in almost the same form..

4. Maintain a High Degree of Reusability

Since each keyword defines an entire sequence of functional operations to perform, one keyword can cover an entire course. This means that you can develop new test cases easily by reusing existing keywords. 

For instance, if you already have a keyword called “OpenMenu” and you want to test a function from a certain menu, your new test can first run “OpenMenu,” rather than again scripting out all the operations necessary to open the menu. As a result, you only need one main driver script to manage the entire implementation process.

Moreover, if there’s a bug in the “OpenMenu” test, you only need to correct it in that test, whereas if you had copied over a part of your script that opens a menu into a number of tests, you would have to fix the errors in each one. This results in a relatively lower amount of necessary maintenance in the long run than scripting tests.

Utilize Automated Testing To Streamline Your Keyword Implementation

Automated testing lets you run far more tests with far less potential for errors than manual testing, helping you speed up your application’s testing process. It also removes the barrier of technical knowledge, allowing you to hire nontechnical testers who don’t have a deep knowledge of the programming language you’re using.

If you want to access these benefits for your keyword implementation, Ranorex’s software offers easy-to-use codeless automation tools that anyone can understand. Those who have basic programming knowledge can enjoy even more customizability with Ranorex Studio’s full development environment. Try Ranorex Studio to find out how much you can accelerate your software testing.

Related Posts:

Software Testing Trends to Keep in Mind for 2023

Software Testing Trends to Keep in Mind for 2023

When you work in the software industry, continuous testing is the name of the game. From quality assurance tests to blockchain testing, understanding, performing, and interpreting tests in an efficient manner is an integral part of the software development life...

Test Data_ How To Make Sense of It

Test Data_ How To Make Sense of It

One of the challenges of software production is the QA (quality assurance) process. You want your end users to have the absolute best experience once your software rolls out. To make that happen, you first need to test your software with numerous scenarios.  One way...