问题
I have the following structure:
test_init
|__________resources
| |__________ keywords.robot
|__________tests
|__________ __init__.txt
|__________ TestInit.robot
The keywords.robot contains:
*** Keywords ***
Keyword for init
Log init
The __init__.txt contains:
*** Settings ***
Documentation This is from init file
Resource ${EXECDIR}/resources/keywords.robot
The TestInit.robot contains:
*** Test Cases ***
Testing the Init
Log Vimal
Keyword for init
And from command line in the test_init directory, if I execute as follows:
> pybot tests
I get the error saying that:
No keyword with name 'Keyword for init' found
I was thinking, the initialization file imports the resource file as well. But the init file is recognized for the documentation and I get that in my report.
I'm bit confused on the usage of initialization file, kindly help me to understand it much better.
回答1:
The use of init file is to manage setup, teardown and tags on your whole folder/suite (and subfolders).
Init files can not be used to import resources (they have to be loaded in the file you use them).
Documentation has been made more clear since 2.8.7: see the Initialization Files section of the user guide.
来源:https://stackoverflow.com/questions/26610579/init-txt-in-robot-framework