Repository navigation
Description
If the current planning holds, Robot 7.5 will include test metadata. See #4409.
We already have suite metadata.
Does it make sense to complete the list with Keyword metadata?
Why this may be useful
Recently, I've come up with some separate use cases that could benefit from keyword metadata.
1. Concurrency settings
Medusa uses suite metadata to calculate which tests can run in parallel. It's a clever approach that can be stretched. A tool like Medusa could use keyword metadata like a kind of lock.
The concept of locks already exists with keyword calls in PabotLib. It can be used to prevent multiple test processes from doing the same thing at the same time. For example, when writing to a file you want to lock that operation to prevent race conditions that cause corrupted files. This approach would be metadata-based instead of keyword-based. This could look something like:
Update A Data File
[Arguments] ${path} ${new_content}
[Metadata] medusa:lock
# change the fileOr, maybe
Update A Data File
[Arguments] ${path} ${new_content}
[Medusa] lock
# change the file3. Caching
In CacheLibrary, I now use a keyword to retrieve from cache and another to write to cache. I got a feature request to cache with a listener instead (Lakitna/robotframework-cache#9).
A configuration like this could be made with metadata:
Do Expensive Calculation
[Arguments] ${data}
[Cache] 1 hour
# do a 10-minute calculation3. Decorator
While writing this, I keep thinking that these examples are essentially Python's @decorators.
@amazing_decorator
def some_function:
passWith keyword metadata, this can be made in Robot like:
Some Keyword
[Metadata] amazing_decoratorOn the Library-side, this should be implemented in a listener. If the listener encounters their special metadata string (here: amazing_decorator), it can wrap the keyword like a Python decorator does. The library can now, essentially do advanced keyword setup and teardown.
4. Temporary Library config
Keyword metadata could be used to overwrite some library configs if the library supports this.
Wait For Super Long And Annoying Animation
[Selenium:timeout] 10 minutesThis would require explicit support from the libraries.
Existing alternatives
To make something like this now, you'd have to use tags, magic docstrings, stick with keywords, or use [Setup] and [Teardown].
Magic tags
Do Expensive Calculation
[Arguments] ${data}
[Tags] cache:3600
# do a 10-minute calculationMagic docstrings
Do Expensive Calculation
[Documentation] Lorum ipsum dolor sit amet
... *CACHE:3600*
[Arguments] ${data}
# do a 10-minute calculationKeywords
Do Expensive Calculation
[Arguments] ${data}
${cached} = Cache Retrieve value amazing_key
IF $cached is not $None
RETURN ${cached}
END
# do a 10-minute calculation
Cache Store Value amazing_key ${outcome}
RETURN ${outcome}Setup and Teardown settings
Update A Data File
[Arguments] ${data}
[Setup] Cache Retrieve value
# do a 10-minute calculation
[Teardown] Cache Store valueNon-library uses
I'm not sure if this is useful outside the library uses outlined above. I guess you could use it for documentation purposes, but I don't really see the point in a world where [Documentation] and [Tags] already exist.
Activity
pekkaklarck commentedon Mar 25, 2026
If we add test metadata (#4409), for consistency reasons it makes sense to add keyword metadata as well. I consider test metadata more important, though, so let's implement that first and then look at this. Getting both done in RF 7.5 would be great, but doing this later is fine as well.
Let's also limit this issue to simple
[Metadata]syntax that can be used likeI'll submit a separate issue about specifying metadata on different levels without the
[Metadata]orMetadatasetting. In this context it would allow using:[-]Custom keyword settings a.k.a. keyword metadata[/-][+]Keyword metadata[/+]Lakitna commentedon Mar 25, 2026
Sounds like a good way to split it. Once
[Metadata]is supported, it may be a good idea to question the use of the second way of specifying entirely. It adds complexity that arguably doesn't always warrant the gains. But that will also depend on how people use it I guess.I also agree that test metadata has priority over this one. In that sense, it may make more sense to move this post 7.5? Depending on implementation details of test metadata
pekkaklarck commentedon Mar 25, 2026
Let's keep this in RF 7.5 for now. Once test metadata is done, we can see where we are with RF 7.5 and decide what to do with this. Test metadata will also give us a pretty good idea about how big task implementing this will be.