-
-
Notifications
You must be signed in to change notification settings - Fork 24
Description
Problem:
RobotFramework is very lenient on variable types, so to minimize errors while writing test cases I use a lot of strict typing in my python libraries, be it built in types or custom enum classes. The issue is that the RobotFramework layer will not spot if I use a wrong type, even though I explicitly specified it in the keyword definition. See the following example:
keywords.py
class keywords:
def my_python_keyword(myvariable: int):
print(myVariable)
testSuite.robot
*** Settings ***
Library keywords.py
*** Variables ***
${intVar} 8
${strVar} hello world!
*** Test Cases ***
Use My Custom Keywords
My Keyword ${intVar}
My Python Keyword ${intVar}
My Keyword ${strVar}
My Python Keyword ${strVar}
*** Keywords ***
My Keyword
[Arguments] ${myVariable: int}
Log ${myVariable}
Nothing will be spotted until runtime, where a ValueError would be raised for the last two keyword calls.
Moreover, declaring a variable with ${var: int} hello
isn't picked up either, until an error is raised at runtime to say that 'var' could not be set.
Requested Enhancement:
Adding type checking as an option for RobotCode would help make test case writing more ergonomic and speed up debugging phases.
As an additional note, this suggestion can probably be linked to suggestion #436 about auto-completion for variables in python variable files.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status