[英]How are Robot Framework Test Suite Directories working precisely?
I am working on a Python library and test suite for testing particular pieces of hardware by using Robot Framework. 我正在研究Python库和测试套件,以通过使用Robot Framework测试特定的硬件。 At that point, I have enough test cases to think about splitting them into several files or even test suites, so I went to the User Guide and found Test Suite Directories section .
那时,我有足够的测试用例,可以考虑将它们分成几个文件甚至测试套件,因此我去了《用户指南》,找到了“ 测试套件目录”部分 。
Following the description, I have created following directory structure: 按照说明,我创建了以下目录结构:
MyPythonLib\
MyPythonLib.py
...
MyTestSuite\
__init__.robot
01_FirstSetOfTests.robot
02_SecondSetOfTests.robot
Common.robot
The __init__.robot
file contains my settings: __init__.robot
文件包含我的设置:
*** Settings ***
Library Dialogs
Library Collections
Resource ../Common.robot
Library ../MyPythonLib/MyPythonLib.py
*** Keywords ***
Some Keywords Specified Here
Then I run the test suite by specifying directory instead of a file, like this: 然后,我通过指定目录而不是文件来运行测试套件,如下所示:
robot MyTestSuite
When doing so, it does not recognize keywords specified in __init__.robot
file, as well as others. 这样做时,它无法识别
__init__.robot
文件中指定的关键字以及其他关键字。 Since all of the settings are taken away from test case files, as I expected them to be included with the __init__
file, this makes me question if the directories are parsed as I understand they should. 由于所有设置都从测试用例文件中删除,正如我希望它们包含在
__init__
文件中一样,这使我怀疑是否按我理解的方式对目录进行了解析。 What am I doing wrong and how can I solve that issue? 我做错了什么,该如何解决呢?
The behavior you describe is documented behavior. 您描述的行为是记录的行为。
From the robot framework user guide (emphasis added): 从机器人框架用户指南 (添加了重点):
Variables and keywords created or imported in initialization files are not available in the lower level test suites .
在较低级别的测试套件中没有在初始化文件中创建或导入的变量和关键字 。 If you need to share variables or keywords, you can put them into resource files that can be imported both by initialization and test case files.
如果需要共享变量或关键字,可以将它们放入资源文件中,该文件可以通过初始化文件和测试用例文件导入。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.