CXTA is a collection of Cisco network test automation libraries built around Robot Framework. Collections from Robot Framework standard libraries, pyATS, Unicon, Genie, and more are included to provide thousands of keywords, enabling test and validation on a wide range of devices and interfaces.
While CXTM supports other automation frameworks and capabilities, CXTA and Robot are the focus of this lab. CXTA and Robot Framework combine to provide a high level of abstraction through the use of higher-level keywords with a natural language expression of test steps.
Robot Framework is an open and extensible automation framework used for test automation. Robot utilizes human-readable keywords leveraging a rich ecosystem of libraries and tools. Capabilities can be extended by Python libraries and user keywords created from existing lower-level keywords. This extensibility allows Robot to be integrated with other tools and environments, and makes it an ideal choice for test automation that requires interacting with different devices, technologies, and interfaces.
Robot Framework leverages multiple file types.
In Robot Framework, test cases are created in executable files that use the .robot extension. Robot documentation refers to these executables as "test case files". In CXTM, these files are generically referred to as "Job Files", and that's the term used in this lab.
Later sections will explain how data should be formatted in Job Files.
Resource files can contain variables and higher-level user keywords. The recommended extension for Resource files is
.resource, but the .robot extension is also acceptable. Resource files are imported into the Job File by using the
Resource setting in the *** Settings ***
section of the Robot Job File as in the following example.
*** Settings ***
Library CXTA
Resource cxta.robot
*** Test Cases ***
1. MY EXAMPLE TEST CASE
Job File sections are explained in more detail below. User keywords can also be defined in the Job File itself, but it's recommended to use resource files to allow the keywords to be used by multiple test cases.
Variable files contain variables that can be used in the Job Files. Like user keywords, variables can be defined within a Job File, but variable files external to the Job File are recommended. Variable files can be created in YAML format and imported into the Job Files much like resource files.
In CXTM, variables can be defined in variable files saved as project or test case attachments and imported into the Job Files. Or they can be stored in a parameter file that's imported by the Job File at runtime.
The content of a Robot Job File is defined in sections.
*** Settings ***
# Used for:
# 1. Importing test libraries, resource files, and variable files
# 2. Defining metadata for test suites and test cases
# 3. Defining Suite Setup and Suite Teardown procedures
*** Variables ***
# Used for:
# Defining variables that can be used elsewhere in the Job File
*** Test Cases ***
# Used for:
# Creating test cases from available keywords
*** Keywords ***
# Used for:
# Creating user keywords from existing lower-level keywords
Sections are recognized by their header, and the recommended header format is *** Settings ***
as seen in the example above. Of the sections discussed here, Settings and Test Cases, are of more importance in this lab.
As mentioned before, both variables and keywords can be defined in a Job File, but it's not recommended.
The most common approach to formatting the content of Robot Job Files is to use the space separated format where pieces of the data, such as keywords and their arguments, are separated with two or more spaces. When using the space separated format, the separator between tokens is two or more spaces or alternatively one or more tab characters.
*** Settings ***
Documentation Example using the space separated format.
Library OperatingSystem
*** Variables ***
${MESSAGE} Hello, world!
*** Test Cases ***
My Test
[Documentation] Example test.
Log ${MESSAGE}
My Keyword ${CURDIR}
Another Test
Should Be Equal ${MESSAGE} Hello, world!
*** Keywords ***
My Keyword
[Arguments] ${path}
Directory Should Exist ${path}
Continue to the next section to add device connection details to your project through a topology file.