Skip to content

[BUG] Templated test case variables are not resolved for embedded arguments #542

@ma-santamaria

Description

@ma-santamaria

Describe the bug
Robotcode does not resolve variables in templated test cases when the template keyword has embedded arguments. A "VariableNotFound" error is shown.

Steps To Reproduce
Steps to reproduce the behavior:

  1. Create a keyword with embedded arguments
  2. Create a templated test case using the previous keyword
  3. See that the template arguments are not resolved

Example:

*** Settings ***
Documentation    Just a simple test suite


*** Test Cases ***
Normal test case with embedded arguments
    [Documentation]    Just a simple test case
    The Result Of 1 + 1 Should Be ${2}
    The Result Of 1 + 2 Should Be ${3}

Template with embedded arguments
    [Documentation]    Just a templated test case
    [Template]    The result of ${calculation} should be ${expected}
    1 + 1    ${2}
    1 + 2    ${3}


*** Keywords ***
The Result Of ${calculation} Should Be ${expected}
    ${result}=    Evaluate    ${calculation}
    Should Be Equal    ${result}    ${expected}

Expected behavior
The variables used as arguments are resolved and no "VariableNotFound" error is shown.

Screenshots/ Videos
VS Code screenshot:

Image

Logs
Robotcode log:

[INFO] Clearing language server caches...
[INFO] Cache clearing completed for all clients
client for file:///c%3A/Users/msantama/code/robotcode-issues stopped.
executeRobotCode: c:\Users\msantama\code\robotcode-issues\.venv\Scripts\python.exe -u -X utf8 c:\Users\msantama\.vscode\extensions\d-biehl.robotcode-2.1.0\bundled\tool\robotcode --format json --no-color --no-pager -dp . profiles list
create Language client: RobotCode Language Server for folder robotcode-issues
trying to start Language client: RobotCode Language Server for folder robotcode-issues
client for file:///c%3A/Users/msantama/code/robotcode-issues starting.
executeRobotCode: exit code 0
client for file:///c%3A/Users/msantama/code/robotcode-issues running.
client for file:///c%3A/Users/msantama/code/robotcode-issues started.
executeRobotCode: c:\Users\msantama\code\robotcode-issues\.venv\Scripts\python.exe -u -X utf8 c:\Users\msantama\.vscode\extensions\d-biehl.robotcode-2.1.0\bundled\tool\robotcode --format json --no-color --no-pager -dp . profiles list
executeRobotCode: c:\Users\msantama\code\robotcode-issues\.venv\Scripts\python.exe -u -X utf8 c:\Users\msantama\.vscode\extensions\d-biehl.robotcode-2.1.0\bundled\tool\robotcode --format json --no-color --no-pager -dp . discover --read-from-stdin all
executeRobotCode: exit code 0
executeRobotCode: exit code 0
executeRobotCode: c:\Users\msantama\code\robotcode-issues\.venv\Scripts\python.exe -u -X utf8 c:\Users\msantama\.vscode\extensions\d-biehl.robotcode-2.1.0\bundled\tool\robotcode --format json --no-color --no-pager -dp . discover --read-from-stdin tests -I templated.robot --suite Robotcode-Issues.Templated
executeRobotCode: exit code 0

RobotCode Language Server log:

[Error - 9:40:24 AM] Server process exited with code 0.

Additional context
The execution of the test case is correct:

==============================================================================
Templated :: Just a simple test suite
==============================================================================
Normal test case with embedded arguments :: Just a simple test case   | PASS |
------------------------------------------------------------------------------
Template with embedded arguments :: Just a templated test case        | PASS |
------------------------------------------------------------------------------
Templated :: Just a simple test suite                                 | PASS |
2 tests, 2 passed, 0 failed
==============================================================================
Output:  C:\Users\msantama\code\robotcode-issues\results\output.xml
Log:     C:\Users\msantama\code\robotcode-issues\results\log.html
Report:  C:\Users\msantama\code\robotcode-issues\results\report.html

Robotcode analyze output:

templated.robot:13:35: [E] VariableNotFound: Variable '${calculation}' not found.
templated.robot:13:60: [E] VariableNotFound: Variable '${expected}' not found.
Files: 1, Errors: 2, Warnings: 0, Infos: 0, Hints: 0

Desktop (please complete the following information):

  • VS Code Version: 1.106.3
  • RobotCode Version: 2.1.0
  • OS: Windows
  • Python Version: 3.13.7
  • RobotFramework Version: 7.3.2
  • Additional tools like robocop: N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions