Bob
Bob

Reputation: 150

Robotframework Change testcase name with variable

Is there any possible to change testcase name with variable like below?

(I don't want to change name from python side)

*** Variables ***
${country}  US

*** Test Cases ***
test_${country}

Upvotes: 0

Views: 1299

Answers (3)

Venkatarao Dadi
Venkatarao Dadi

Reputation: 96

Yes this is supported.

example:-

*** Test Cases ***

Test title ${name}

[Tags]    DEBUG

Log  Welcome ${name}

output:-

robot --variable name:sample eg.robot

enter image description here

Upvotes: 1

Patz
Patz

Reputation: 334

Yes, you can. The way you have shown it should work. Are you facing any issue with that? If yes, pls provide the detailed error.

Upvotes: 1

Nomce
Nomce

Reputation: 775

As far as I know, it isn't possible to use a variable inside a test case name. It follows the same logic as normal Python functions, so normally, it isn't possible.

Instead, you can use the variable in the setup or in the test case directly to modify it's behaviour.

If you want to generate test cases based on a variable, you can write a (python) script that can generate the needed file/test cases with the corresponding values. Or, even better, use an Model-Based Testing tool to produce them.

Upvotes: 0

Related Questions