Repository navigation
feat: added &{TEST METADATA} variable and Set Test Metadata - #5745
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces support for test/task metadata as a first-class, dynamically updatable concept during execution by adding a new built-in variable and BuiltIn keywords, and by extending acceptance tests and user guide documentation accordingly.
Changes:
- Add
${TEST METADATA}/&{TEST METADATA}automatic variable populated at test start and refreshed when metadata is modified. - Add
Set Test MetadataandSet Task Metadatakeywords to update current test/task metadata (with optional append + custom separator). - Extend user guide and acceptance tests to cover the new variable and keywords.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/robot/running/context.py | Initializes the per-test metadata variable at test start. |
| src/robot/libraries/BuiltIn.py | Adds Set Test Metadata + Set Task Metadata keywords and cross-links from suite metadata docs. |
| doc/userguide/src/CreatingTestData/Variables.rst | Documents the new automatic variable in the built-in variables table. |
| atest/testdata/variables/automatic_variables/resource.robot | Adds helper keyword and teardown coverage for the new automatic variable. |
| atest/testdata/variables/automatic_variables/auto1.robot | Adds test cases validating ${TEST METADATA} / &{TEST METADATA} behavior and isolation from real metadata when mutated. |
| atest/testdata/standard_libraries/builtin/set_test_metadata.robot | Adds new test data file for Set Test Metadata / Set Task Metadata keyword behavior. |
| atest/robot/variables/automatic_variables.robot | Verifies metadata appears in execution results and is not affected by mutating the variable. |
| atest/robot/standard_libraries/builtin/set_test_metadata.robot | Adds acceptance tests validating keyword behavior and log messages. |
| atest/robot/standard_libraries/builtin/log_variables.robot | Updates variable logging expectations to include &{TEST_METADATA} and adjusts message counts. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 10 out of 10 changed files in this pull request and generated no new comments.
Suppressed comments (2)
doc/userguide/src/CreatingTestData/Variables.rst:1599
- The automatic variables table lists this as
&{TEST METADATA}, but the BuiltIn keyword docs (and the establishedSUITE METADATAdocs) present metadata variables in scalar form (${...}holding a dictionary). Using different forms across docs is inconsistent and may confuse readers about how the variable is accessed.
| &{TEST METADATA} | The free metadata of the current test case. Can be | Test case |
| | set using :name:`Set Test Metadata` keyword. | |
| | New in Robot Framework 7.5. | |
src/robot/libraries/BuiltIn.py:4804
set_task_metadatadelegates toset_test_metadatausing positional arguments for the optional parameters, which is easy to misread (append vs separator) and becomes brittle if the callee signature changes. Using explicit keyword arguments here improves clarity.
self.set_test_metadata(name, value, append, separator)
pekkaklarck
left a comment
There was a problem hiding this comment.
Lools great! I added two small comments about doc enhancements, but they don't prevent merging this. If you think those doc enhancements make sense, please create a new PR.
| value when appending. | ||
|
|
||
| The metadata of the current test is available as a built-in variable | ||
| `${TEST METADATA}` in a Python dictionary. Notice that modifying this |
There was a problem hiding this comment.
This could mention that the dict is dot-accessible like ${TEST METADATA.Example}. Should also check what the Suite variant says about this.
| | | keyword. | | | ||
| +------------------------+-------------------------------------------------------+------------+ | ||
| | &{TEST METADATA} | The free metadata of the current test case. Can be | Test case | | ||
| | | set using :name:`Set Test Metadata` keyword. | | |
There was a problem hiding this comment.
This implies that the keyword is the only way to set metadata. Changing "can be set" to "can be set dynamically" like with other similar variables would be better.
It would be best to also link to the section discussing test metadata, but for consistency reasons it should be done also with others. Not really related to this feature in general, but enhancing docs is obviously always good.
This pull request adds the built-in variable
${TEST_METADATA}and the keywordsSet Test MetadataandSet Task Metadatato Robot Framework. These changes allow users to set and access test-specific metadata dynamically during test execution.The most important changes are:
New Features
${TEST_METADATA}variable, which exposes the current test's metadata as a dictionary and is updated at test start and when metadata changes.Set Test MetadataandSet Task Metadatakeywords inBuiltIn.pyto allow setting and appending metadata for the current test/task, with options for case/space/underscore-insensitive names and custom separators.Documentation
${TEST_METADATA}variable and its usage in the user guide, including its availability and the new keywords.