robotframework / robotframework/robotframework

Reloading user keywords within a suite

Open
#5,049 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
11.9k
Forks
2.6k
Avg merge
1d 18h
Merged PRs (30d)
10

Description

This use case might be rare but we are currently suffering from it. It relates to functionality where resource file can be loaded with using variables in the name like:

Resource    system/${DEVICE}/common.resource

The problem arises when the value of the ${DEVICE} is changed and the keywords from the new location needs to be loaded within the same suite. Normally, resource files are loaded when entering a suite and cannot be reloaded unlike libraries.

It is possible to load keywords from a new resource file using:

Import Resource    system/${DEVICE}/common.resource

New keywords are added fine but if there are keywords with same names already been load, the RF starts to complain these keywords having the same name.

The Set Library Search Order won’t fix this problem as it only possible to give it the filename (common.resource) which in above use case is the same.
There would be another way use variables in resource names:

Import Resource    system/${DEVICE}_common.resource

But even now the Set Library Search Order doesn’t seem to work as expected like if used in this ways:

Set Library Search Order    ${DEVICE}_common.resource

Anyway using Set Library Search Order would add complexity to the implementation and if there would be many “DEVICE” options you would end up loading lot of resource files with same keywords.

Nicest solution would be to have keyword similar to Reload Library: Reload Resources Builtin.

This would reload all the resource file in a suite (and clearing previously loaded keywords) using updated variables in the resource filenames.

Some example code can be found here: rf-resource-issue

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the existing Import Resource and Reload Library behavior, then use the linked rf-resource-issue example to reproduce variable-based resource loading. Done means a Reload Resources BuiltIn reloads suite resource files with updated variables, removes previously loaded keywords, and avoids duplicate-name conflicts.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
testing-qa
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.