user7982813
user7982813

Reputation: 151

How to use run a keyword if testcasename is equal to abc in robotframework

I know how can we use run keyword if specific condition is met but i want to run a keyword if testcasename matches.

run keyword if testcase=abc.robot

does anyone know how can we achieve that.

Upvotes: 1

Views: 4313

Answers (2)

Jan Kovařík
Jan Kovařík

Reputation: 1582

Run Keyword If '${TEST_NAME}'=='<your_test_name>' <Keyword> <args>

Upvotes: 0

Bryan Oakley
Bryan Oakley

Reputation: 385830

Robot framework provides several automatic variables -- variables that are set automatically by the framework. One such variable is ${TEST_NAME}.

In the following example, only the log statement in the second test will run:

*** Test Cases ***
Example 1
    run keyword if  "${TEST_NAME}" == "Example 2"
    ...   log  this is example 2?

Example 2
    run keyword if  '${TEST_NAME}' == "Example 2"
    ...  log  this is example 2!

Upvotes: 2

Related Questions