__init__.txt in Robot Framework

ぐ巨炮叔叔 提交于 2019-12-06 11:07:33

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!