Robot Framework snippets for VS Code

I posted this in the Slack workspace, but thought I’d make a post here for longevity.

I recently created a Gist of robotframework.code-snippets for use with VS Code.

If you’re not familiar with VS Code snippets, here’s some info. The TL;DR is that you just type some short-hand and VS Code suggests the macro expansion for you.

For example, if I begin to type suite in a new file that I’ve told VS Code is a :robot: file, I get this:

*** Settings ***
Documentation     What does this testing suite cover?

Library           String  # just an example
Library           ${EXECDIR}/path/to/CUSTOM_LIBRARY.py
Resource          ${EXECDIR}/path/to/NAME_OF_ANOTHER.resource

Suite Setup       SETUP_HERE
Suite Teardown    TEARDOWN_HERE


*** Variables ***
${SOME_TEXT}    Hello
${AN_INT}       ${42}
@{A_LIST}       All    Cows    Eat    Grass
&{A_DICT}       StrKey=A string    IntKey=${22}


*** Test Cases ***
EXAMPLE TEST CASE (use 'tc' snippet instead)
    [Documentation]    DOCS HERE
    [Tags]  TAGS_HERE
    [Setup]    SETUP_HERE
    No Operation
    [Teardown]    TEARDOWN_HERE


*** Keywords ***
EXAMPLE KEYWORD (use 'kw' snippet instead)
    [Documentation]    Move this to resource file later
    [Arguments]  ${param_1}  ${param_2}  # if args are needed...
    No Operation


*** Comments ***
These comments are entirely ignored! Write a pie recipe if you want!

GIF of using the Keyword (kw) snippet:
keyword_snippet_demo

It’s especially helpful that you included examples of how the snippets expand—this makes it easy for newcomers to see the potential benefits right away. Plus, the GIF showcasing the keyword snippet in action is a nice touch!

3 Likes