Skip to content

Automatically select "best" match if there is conflict with keywords using embedded arguments #4454

@pekkaklarck

Description

@pekkaklarck

Currently the following test (adapted from an example in a comment to #4069) fails:

*** Test Cases ***
Example
    Execute "x" on device "y"

*** Keywords ***
Execute "${command}"
    Log    Executing ${command}.

Execute "${command}" on device "${device}"
    Log    Executing ${command} on ${device}.

The reason for the failure is that Execute "x" on device "y" matches both of the keyword implementations. A solution to this problem, recommended in the User Guide, has been using custom patterns that limit what keywords match. For example, changing the first keyword to Execute "${command:[^"]+}" would mitigate the issue.

Issue #4069 proposes making custom patterns more strict so that they would be validated also when the argument is given as a variable. As the comment referenced above explains, this unfortunately causes problems if patterns have been used for resolving conflicts as explained above.

A solution to the problem caused by conflicts, that would also allow us making custom pattern validation more strict, would be Robot somehow being able to detect what is the "best" match. For a human it is pretty clear that if you use Execute "x" on device "y", Execute "${command}" on device "${device}" matches better than Execute "${command}", but the problem is how Robot can detect that. It's also a question that can it always detect it right or could there be false positives. I have one pretty simple approach in mind that I explain in a separate comment. Other approaches can also be proposed!

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions