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

Variables inside of classes in Variable Files are not recognized by the validations rules. #242

Closed
daveesposito opened this issue Sep 5, 2018 · 4 comments
Assignees
Milestone

Comments

@daveesposito
Copy link

Example:

I have a variable file which contains the following:

class CATEGORY:
    ONE = "1"
    TWO = "2"

When I attempt to import this variable file into a test suite file it generates a warning "Could not find any variable in file '...'". Also, attempting to use the variables ${CATEGORY.ONE} or ${CATEGORY.TWO} (which is valid in Robot Framework) generates an error "Variable '...' is used but not defined".

Since this pattern is allowed by Robot Framework the variables should be recognized as valid.

@atiasn
Copy link

atiasn commented Sep 6, 2018

RobotFramework UserGuide Doc. resource-and-variable-files

Implementing variable file as Python or Java class

Starting from Robot Framework 2.7, it is possible to implement variables files as Python or Java classes.

Implementation

Because variable files are always imported using a file system path, creating them as classes has some restrictions:

  • Python classes must have the same name as the module they are located.
  • Java classes must live in the default package.
  • Paths to Java classes must end with either .java or .class. The class file must exists in both cases.

@michalanglart
Copy link
Collaborator

Hi,

this requires some investigation on our side. As @XiaoyaoRay pointed out the User Guide states that the class should have same name as the module.

In your example if you rename your module to CATEGORY you will properly be able to use ONE as well as TWO variables and RED will not complain.

This is true however that Robot allows to use ${CATEGORY.ONE} syntax and runs happily despite of what is stated in user guide.

We need to take a look at this deeper.

@daveesposito
Copy link
Author

Yes, my observation is that I can have multiple classes in a variable file and when I run the tests Robot Framework will correctly identify all variables. Also, they are recognized in RIDE as well.

@michalanglart michalanglart self-assigned this Sep 20, 2018
@michalanglart michalanglart added this to the 0.8.8 milestone Sep 20, 2018
red-common-CI pushed a commit that referenced this issue Sep 28, 2018
The classes from imported variable files are also visible as variables.
@michalanglart
Copy link
Collaborator

Closing - released in 0.8.8

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

No branches or pull requests

3 participants