Robot Framework 中的 __init__.txt

Vim*_*vam 2 robotframework

我有以下结构:

test_init
|__________resources
|          |__________ keywords.robot
|__________tests
           |__________ __init__.txt
           |__________ TestInit.robot
Run Code Online (Sandbox Code Playgroud)

keyword.robot 包含:

*** Keywords ***
Keyword for init
   Log  init
Run Code Online (Sandbox Code Playgroud)

__init__.txt 包含:

*** Settings ***
Documentation  This is from init file
Resource  ${EXECDIR}/resources/keywords.robot
Run Code Online (Sandbox Code Playgroud)

TestInit.robot 包含:

*** Test Cases ***
Testing the Init
   Log  Vimal
   Keyword for init
Run Code Online (Sandbox Code Playgroud)

并从 test_init 目录中的命令行,如果我执行如下:

> pybot tests
Run Code Online (Sandbox Code Playgroud)

我收到错误说:

No keyword with name 'Keyword for init' found
Run Code Online (Sandbox Code Playgroud)

我在想,初始化文件也导入了资源文件。但是 init 文件被文档识别,我在我的报告中得到了它。

我对初始化文件的用法有点困惑,请帮助我更好地理解它。

Lau*_*iel 5

init 文件的用途是管理整个文件夹/套件(和子文件夹)上的设置、拆卸和标签。

init 文件不能用于导入资源(它们必须加载到您使用它们的文件中)。

自 2.8.7 以来,文档变得更加清晰:请参阅用户指南的初始化文件部分。