Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect validation of Test Setup in Initialization files #427

Open
Zeckie opened this issue Jun 8, 2021 · 2 comments
Open

Incorrect validation of Test Setup in Initialization files #427

Zeckie opened this issue Jun 8, 2021 · 2 comments

Comments

@Zeckie
Copy link

Zeckie commented Jun 8, 2021

RED doesn't correctly validate that keywords used in Test Setup and Test Teardown in a suite initialization file (__init__.robot) need to be defined in the test case file, not the initialization file.

Test Setup, Test Teardown, Test Timeout
Set the default value for test setup/teardown or test timeout to all test cases this directory contains. Can be overridden on lower level. Notice that keywords used as setups and teardowns must be available in test case files where tests using them are. Defining keywords in the initialization file itself is not enough.
(http://robotframework.org/robotframework/3.2.2/RobotFrameworkUserGuide.html#initialization-files)

Case 1:

Library imported in initialization file. This makes RED happy, but doesn't make the library accessible to the test setup.

image
image

Case 2:

Library is imported in the test case file, but not in the initialization file. This runs fine but RED doesn't like it.

image
image

Case 3:

Library imported using Import Library keyword as part of Test Setup, to avoid having to import the library in every test case file. This is valid, but RED doesn't seem to understand the Import Library keyword.

image
image

Workaround:

To make both RED and RobotFramework happy, combine Case 1 with either Case 2 or Case 3

eg.
image
image

@michalanglart
Copy link
Collaborator

Hi,

this is problematic because it may be OK for some of the tests down below init file in the suites hierarchy while for others it may be wrong. Now depending if you would run the suite which imports the library or the one which does not the result in Robot would be different too.

@Zeckie
Copy link
Author

Zeckie commented Jun 20, 2021

I think each test / task within each robot file would need to be validated to determine which setup / teardown would be used for that test, and whether the keywords used in them have been imported / defined.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants