Introduction¶
Keyword-driven testing is a software testing methodology which uses keywords (or action words) to symbolize a functionality to be tested. This method separates the description of the tests from its implementation and therefore reduces the future maintenance time caused by changes in the AUT. In the case of GUI changes in the AUT, only very small changes or even no changes have to be completed in test case documentation. Some changes need to be applied to keyword documentation only.
Robot Framework is a test automation framework which utilizes the keyword-driven testing approach. Its advantage is that users can create new higher-level keywords from existing ones. To integrate the Squish GUI Testing tool with Robot Framework, the keywords library needs to be implemented with Python using the squishtest module.
As an example, the Qt AddressBook application was chosen, which ships with Squish for Qt. Using a similar approach, we can automate Java, Windows, Mac, iOS, Android and Web applications.
Example¶
Robot Test Case¶
A test case can be defined in a plain text file with the txt extension. Test cases are constructed in test case tables and built from the available keywords. Keywords can be imported from test libraries or resource files (e.g. resource.txt
). The first column in the test case table contains test case names (e.g. Add Entry
, Empty AddressBook
). The second column normally contains keyword names (e.g. New Addressbook
, Add Entry
), columns after the keyword name contain possible arguments for the specified keyword (e.g. Tom Paw tom@m.com 12345
). Additionally we can define test setup and teardown actions. A test setup is something that is executed before a test case, and a test teardown is executed after a test case. In the example below the Start AddressBook
keywords is executed before every test case.
Keywords Resource File¶
A resource file contains keywords definitions that are used in test cases.
To define keywords we utilize low level keywords provided by the SquishLibrary
(see "Low Level Keywords Library" below).
Low Level Keywords Library¶
The following example library "SquishLibrary" contains "low level" keywords, that is, keywords that are actually defined in Python code.
It utilizes the Squish Python module
squishtest
, which allows us to use the Squish functions in Python code.
These low level keywords are meant to be used in our *.resource file mentioned above.
Executing the Example¶
Requirements¶
- The extracted example archive squish_with_robot_framework.zip .
- A Squish for Qt installation.
- A separate Python installation with the Robot Framework 5.1 or higher installed in it.
Note: The separate Python installation must have the same Python 2 or Python 3 major and minor version as the Python installation in the Squish for Qt installation, as well as the same architecture.
General Example Execution¶
Start cmd.exe
/ Command Prompt and execute the following commands in it:
cd "path\to\squish_with_robot_framework"
execute_tests_qt_addressbook.bat "path\to\python_with_robot_framework" "path\to\squish_for_qt"
(Replace "path\to\python_with_robot_framework" and "path\to\squish_for_qt" as needed.)
Specific Example Execution & Output¶
cd "C:\Users\myuser\squish_with_robot_framework"
execute_tests_qt_addressbook.bat "C:\Python38-64\python.exe" "C:\Users\myuser\squish-7.0.0-qt62x-win64-msvc142"
==============================================================================
Addressbook Tests
==============================================================================
Addressbook Tests.Add Entry :: A test suite with two tests for addressbook.
==============================================================================
Empty AddressBook | PASS |
------------------------------------------------------------------------------
Add Entry | PASS |
------------------------------------------------------------------------------
Addressbook Tests.Add Entry :: A test suite with two tests for add... | PASS |
2 tests, 2 passed, 0 failed
==============================================================================
Addressbook Tests | PASS |
2 tests, 2 passed, 0 failed
==============================================================================
Output: C:\Users\myuser\squish_with_robot_framework\results\output.xml
Log: C:\Users\myuser\squish_with_robot_framework\results\log.html
Report: C:\Users\myuser\squish_with_robot_framework\results\report.html