You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1. Created as a user keyword in the same file where it is used. These keywords have the highest priority and they are always used, even if there are other keywords with the same name elsewhere.
Robot Framework does not actually behave likes this when it comes to resource files. Consider the following three files:
Resource1.robot:
*** Keywords ***
A
Log Resource1
Resource2.robot:
*** Keywords ***
A
Log Resource2
B
A
TestSuite1.robot:
*** Settings ***
Resource Resource1.robot
Resource Resource2.robot
*** Test Cases ***
Test Case 1
B
Attempting to run TestSuite1.robot will fail with the following message:
FAIL : Multiple keywords with name 'A' found. Give the full name of the keyword you want to use:
Resource1.A
Resource2.A
So keyword B uses keyword A, which is "[c]reated as a user keyword in the same file where it is used". According to the documentation, this should just work. Yet it doesn't.
1. Created as a user keyword in the same test case file where it is used. These keywords have the highest priority and they are always used, even if there are other keywords with the same name elsewhere.
You may also want to add something like:
Note
When a test case file defines a keyword, all uses of keywords with the same name in resource files will be overridden, unless they use the full name of the keyword as explained in the next section.
Also, I'd like to use this opportunity to thank you for creating such an awesome piece of software, maintaining and improving it through the years and letting us use it for free. Much, much, much appreciated 🙂!
The text was updated successfully, but these errors were encountered:
I've been thinking some more on this, and maybe this would be a better replacement for the first keyword scope rule:
1. Created as a user keyword in the test case file that is currently being executed. These keywords have the highest priority and they are always used, even if there are other keywords with the same name elsewhere.
This better covers how Robot Framework seems to work. My knowledge is still limited, though, so correct me if I'm wrong 🙂
Also, even with this version of the scope rule, I'd still like to see the aforementioned Note added. Not knowing that test-case-file-defined keywords override uses in imported resource files can cause some very, very unexpected behavior 😇
True, the docs should mention that keywords in the same file as the test case have highest priority. I'll use this:
Created as a user keyword in the currently executed test case file. These keywords have the highest priority and they are always used, even if there are other keywords with the same name elsewhere.
Under https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#keyword-scopes, the docs state that the following rule is used when determining keyword priority:
1. Created as a user keyword in the same file where it is used. These keywords have the highest priority and they are always used, even if there are other keywords with the same name elsewhere.
Robot Framework does not actually behave likes this when it comes to resource files. Consider the following three files:
Resource1.robot:
Resource2.robot:
TestSuite1.robot:
Attempting to run TestSuite1.robot will fail with the following message:
So keyword B uses keyword A, which is "[c]reated as a user keyword in the same file where it is used". According to the documentation, this should just work. Yet it doesn't.
Considering the way namespacing is actually implemented, I'd suggest updating this line of documentation by adding "test case":
1. Created as a user keyword in the same test case file where it is used. These keywords have the highest priority and they are always used, even if there are other keywords with the same name elsewhere.
You may also want to add something like:
Also, I'd like to use this opportunity to thank you for creating such an awesome piece of software, maintaining and improving it through the years and letting us use it for free. Much, much, much appreciated 🙂!
The text was updated successfully, but these errors were encountered: