Robot Framework get name of current test case

Just as additional comment and idea, if you want to handle files and more complex logic, have more control, it's perhaps good idea to write your custom robot library in Python.

When doing that, you can access also the "automatic variables" or built-in robot vars this way:

from robot.libraries.BuiltIn import BuiltIn
BuiltIn().get_variable_value("${TEST NAME}")

Also, there is a ${SUITE NAME} variable that holds the main txt file's name.


After a bit of digging, I was able to find this in the documentation:

There is a built-in variable ${TEST NAME}, so my test case would look like:

*** Settings ***
Test Setup  Load Test Data

*** Keywords ***
Load Test Data
    ${data}=  Get File  ${TEST NAME}.txt
    Set Test Variable  ${data}  ${data}

*** Testcases ***
First Test
    Log  ${data}

Second Test
    Log  ${data}