简体   繁体   中英

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. 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:

*** 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. 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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM