CXTA
CXTM Test Automation
  • Introduction
  • CXTM Basics
  • CXTM Projects
  • CXTM Test Cases
  • CXTM Test Automation
  • Revisit Imported Test Cases
  • CXTM Batches
  • CXTM Notifications
  • NetDevOps
  • CXTM Reporting
  • CXTM References
  • Bonus: Project Users
  • Bonus: CXTM REST API
  • Bonus: Secret Env Variables

CXTA and Robot Framework

CX Test Automation (CXTA)


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. Support includes, but is not limited to, the following.

  • Cisco network devices (IOS-XE, IOS-XR, NXOS, and more)
  • Generic CLI interaction with any system via telnet or ssh
  • REST/RESTCONF APIs of components like NSO, BPA, etc
  • Graphical User Interface (GUI) testing (via Selenium)
While CXTM supports other automation frameworks, such as pyATS and Ansible, 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. This low code approach allows traditional network engineers an approachable path to understanding and developing test automation, without having to develop extensively in python.


What is Robot Framework?


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.


Why Robot Framework?


Here are some of the many reasons why CXTM and multiple test and validation based service offers at Cisco have chosen to leverage Robot for test automation.

Robot Framework:

  • Is platform and application independent
  • Has a modular architecture supporting diverse interfaces
  • Supports testing web applications, REST APIs, and connecting to devices via Telnet, SSH, and so on
  • Provides an easy-to-use syntax for creating test cases
  • Provides ability to create reusable higher-level (user) keywords from existing keywords
  • Provides suite-level setup and teardown
  • Has built-in support for variables for testing in different environments
  • Provides easy-to-read result reports and logs in HTML format
  • Enables easy integration with source control


Robot File Types

Robot Framework leverages multiple file types.

Job Files

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 throughout this lab.

Later sections will explain how your code should be formatted in Job Files.

Resource 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 is generally recommended to use resource files to allow the keywords to be used by multiple test cases.

Variable files

Variable files contain variables that can be used in the Job Files. Like user keywords, variables can also be defined within a Job File, depending on the variable scope. 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 gets imported by the Job File at runtime.


Robot Job File Sections

The content of a Robot Job File is defined in sections, with standard section headers.


*** 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.


Robot Job File format

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.