Skip to content

feat: added &{TEST METADATA} variable and Set Test Metadata - #5745

Open
febb0e wants to merge 3 commits into
robotframework:masterfrom
imbus:feature/test-metadata-variable
Open

feat: added &{TEST METADATA} variable and Set Test Metadata#5745
febb0e wants to merge 3 commits into
robotframework:masterfrom
imbus:feature/test-metadata-variable

Conversation

@febb0e

@febb0e febb0e commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

This pull request adds the built-in variable ${TEST_METADATA} and the keywords Set Test Metadata and Set Task Metadata to Robot Framework. These changes allow users to set and access test-specific metadata dynamically during test execution.

The most important changes are:

New Features

  • Added the ${TEST_METADATA} variable, which exposes the current test's metadata as a dictionary and is updated at test start and when metadata changes.
  • Introduced the Set Test Metadata and Set Task Metadata keywords in BuiltIn.py to allow setting and appending metadata for the current test/task, with options for case/space/underscore-insensitive names and custom separators.

Documentation

  • Documented the new ${TEST_METADATA} variable and its usage in the user guide, including its availability and the new keywords.

Copilot AI lite review requested due to automatic review settings August 13, 2026 13:47
@febb0e febb0e mentioned this pull request Aug 13, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Metadata and Set Task Metadata keywords 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.

Copilot AI review requested due to automatic review settings August 14, 2026 08:17

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 established SUITE METADATA docs) 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_metadata delegates to set_test_metadata using 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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants