Multiple releases, limited resources, time pressure and a team with mixed skillsets. And it’s your task to create flexible, maintainable automated tests, which every team member can understand and work with. The solution: get a test automation tool that supports keyword-driven testing.
What is keyword-driven testing?
The keyword-driven testing approach separates the test automation implementation from the test case design. A keyword is defined for each action in the test case. Once the keyword is set, you don’t need any programming knowledge to easily design and maintain the automated tests.
What are the benefits of keyword-driven testing?
- Tests are easily readable.
As keyword-driven tests are technology-independent, they’re easily readable for non-technical testers. While technically experienced team members can prepare the automation process and define keywords, you don’t need any technical knowledge to design test cases with these keywords.
- You can create flexible, easily maintainable tests faster.
In keyword-driven testing, each action is automated only once and the corresponding keyword can be reused throughout several test cases.
How can I create keyword-driven tests with Ranorex?
There are two ways of creating keyword-driven tests with Ranorex:
- Option 1: Keyword-driven framework with automation modules
You can follow this approach without writing a single line of code.
- Option 2: Keyword-driven framework using the action table
We recommend basic programming knowledge when following this more advanced approach.
1. Keyword-driven framework with automation modules
You can use both your recording and code modules in Ranorex Studio as a basis for keyword-driven testing. Simply split your automation modules and give them each a clearly understandable name. For example, you can define a set of actions, which start the system under test, as a module with the name “StartSUT”. You can find detailed information on how to do so in this user guide section .
These modules now function as keywords. Once the keywords are defined, you can drag and drop the keywords needed for your test directly from the module browser into your test suite.
Reuse keywords in multiple projects
Start by creating your keywords directly in a Ranorex test suite module library. You then use these keywords in multiple Ranorex projects by referencing back to this library. You can do so in two different ways:
- Reference the Ranorex test suite module library. This enables you to still edit the keywords when needed.
- Reference the DLL file of the Ranorex test suite module library. Please note that this approach doesn’t allow you to modify your keywords.
This approach completely separates the keyword implementation from the test case design and the keyword usage.
If you want to learn more about organizing test automation projects, please read this blog post: “ Organize a Test Automation Project with Ranorex “.
Use external data in keyword-driven tests
You can make your tests even more flexible by using variables. Variables enable you to automatically retrieve external data, which you’ve saved in an Excel or CVS sheet, in your tests – such as passwords for login actions. You can find detailed information on how to implement this type of testing in our user guide section “Data-Driven Testing“.
2. Keyword-driven testing using the action table
We bet you’re familiar with the good old Excel-spreadsheet. So why not use something you already know well in your automated tests? When using the action table in the Ranorex Recorder, you can create keyword-driven tests in a table-like workspace. It just takes a little trick to access your predefined keywords within this view: Inheritance.
Technically experienced team members can provide code-based keywords in a code module. You find detailed information on how to do so in this user guide section orthis blog post.
A recording module, which is inherited from a code module, automatically derives all functionalities from its parent module. This is also true for parameters – you can read more about this topic in the user guide section “ User Code Actions and Parameters ”.
This can be achieved with inheritance in the recording modules “UserCode.cs” file:
Now, you can simply add a user code action in the action table (Add New Action -> User Code) and choose a predefined keyword. Once you’ve defined it, you can set the argument.
You can also use data-driven testing within the recording module by simply making the keyword parameters variable as explained in the user guide section “Data-Driven Testing“.
Keyword-driven test automation is a fantastic way to create flexible test cases. It enables teams with different technical background to work on test automation projects together, while keeping test clearly structured and easily maintainable.