Wiki

Clone wiki

PygmentsLexer / Home

Introduction

This project implements a Pygments lexer for Robot Framework test data in plain text format. It is available as a separate plugin and included in Pygments 1.6 and newer.

What is Pygments

Pygments is a generic library/tool for syntax highlighting. It is used by many different applications and wikis, including the wiki here in BitBucket.

What is Robot Framework

Robot Framework is a generic test automation framework suitable both for normal test automation and Acceptance Test Driven Development (ATDD). Its test data is defined in tabular format either in plain text, TSV, or HTML files. The target of this project is to provide syntax highlighting for the plain text format.

Installation

$ pip install pygments
$ pip install robotframeworklexer

Starting from Pygments 1.6 this lexer is built-in to Pygments and the latter step is not be needed anymore.

Usage

After installation Pygments will recognize robotframework lexer. It can be used, for example, with pygmentize tool:

$ pygmentize -l robotframework tests.txt

See generate.py script for an example of the programmatic usage. For general information about using Pygments, consult its documentation and/or the documentation of the tool you are using it with.

Example

Click here to see how the following example looks like when the syntax is highlighed using Pygments built-in autumn styles. When this lexer is integrated with Pygments. and BitBucket has upgraded to that Pygments version, you should see syntax highlighting also below.

*** Settings ***
Documentation    Simple example demonstrating syntax highlighting.
Library          ExampleLibrary
Test Setup       Keyword    argument   argument with ${VARIABLE}

*** Variables ***
${VARIABLE}      Variable value
@{LIST}          List    variable    here

*** Test Cases ***
Keyword-driven example
    Initialize System
    Do Something
    Result Should Be    42
    [Teardown]    Cleanup System

Data-driven example
    [Template]    Keyword
    argument1   argument2
    argument    ${VARIABLE}
    @{LIST}

Gherkin
    Given system is initialized
    When something is done
    Then result should be "42"

| Pipes |
|  | [Documentation] | Also pipe separated format is supported. |
|  | Log | As this example demonstrates. |

*** Keywords ***
Result Should Be
    [Arguments]    ${expected}
    ${actual} =    Get Value
    Should be Equal    ${actual}    ${expected}

Then result should be "${expected}"
    Result Should Be    ${expected}

License

Apache License, Version 2.0.

Updated