Robot Framework 中的 __init__.txt [英] __init__.txt in Robot Framework

查看:77
本文介绍了Robot Framework 中的 __init__.txt的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下结构:

test_init
|__________resources
|          |__________ keywords.robot
|__________tests
           |__________ __init__.txt
           |__________ TestInit.robot

keywords.robot 包含:

The keywords.robot contains:

*** Keywords ***
Keyword for init
   Log  init

__init__.txt 包含:

The __init__.txt contains:

*** Settings ***
Documentation  This is from init file
Resource  ${EXECDIR}/resources/keywords.robot

TestInit.robot 包含:

The TestInit.robot contains:

*** Test Cases ***
Testing the Init
   Log  Vimal
   Keyword for init

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

And from command line in the test_init directory, if I execute as follows:

> pybot tests

我收到错误消息:

No keyword with name 'Keyword for init' found

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

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.

推荐答案

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

The use of init file is to manage setup, teardown and tags on your whole folder/suite (and subfolders).

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

Init files can not be used to import resources (they have to be loaded in the file you use them).

文档从 2.8.7 开始变得更加清晰:参见 初始化用户指南的文件部分.

Documentation has been made more clear since 2.8.7: see the Initialization Files section of the user guide.

这篇关于Robot Framework 中的 __init__.txt的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆