2
votes

Confused with the significance of Resource file and Variable file in RoboFramework:

My understanding is "the files are used to import variables/keywords" as per the official link:

Resource File : "The user keywords and variables defined in a resource file are available in the file that takes that resource file into use"

Variable File : "Variable files contain variables that can be used in the test data."

What is the difference in these files and when these can be used ??

1

1 Answers

4
votes

As the documentation states, a variable file is for importing variables. This is its only purpose. Variable files are usually python, which gives you a lot of flexibility. For example, you can define a variable based on the platform, or whether a file exists or not, etc.

Variable files are also very useful if the data you want to define is more than a simple string. Using python syntax it's possible to define variables that are lists, dictionaries, or even python objects. While you can do dicts and lists using robot syntax, it can be very cumbersome.

Resource files let you import keywords and variables using the robot syntax. In my experience, resource files are most often used for keywords, and less frequently as a way to import large amounts of variables.