Skip to content

Test Metadata setting to set default metadata for tests #5769

Description

@febb0e

Test/task level metadata was added in #4409 / #5685 but unlike other test related settings
[Metadata] has no matching setting in the *** Settings *** section. As @pekkaklarck already mentioned in
#4409 (comment):

While reviewing the docs I realized that [Metadata] doesn't have a matching setting in the
Settings section similarly as other settings have. We could introduce a separate
Test Metadata (and Task Metadata) setting that would specify the default metadata and
[Metadata] could then add new and modify values similarly as [Tags] can modify tags set
with Test Tags. [...] The only design decision I see is agreeing on syntax how to remove
metadata. Probably using -Name like you can use -tag with tags would be best.

This issue is about this enhancement.

Syntax proposal

*** Settings ***
Test Metadata    Owner       QA Team
Test Metadata    Priority    Normal

*** Test Cases ***
Use Defaults
    [Documentation]    Metadata is `Owner: QA Team` and `Priority: Normal`.
    No Operation

Override Test Metadata
    [Documentation]    Metadata is `Owner: QA Team` and `Priority: Critical`.
    [Metadata]    Priority    Critical
    No Operation

Add New Test Metadata
    [Documentation]    Metadata is `Owner: QA Team`, `Priority: Normal` and `Issue: 4409`.
    [Metadata]    Issue    4409
    No Operation

Remove Test Metadata
    [Documentation]    Metadata is only `Priority: Normal`.
    [Metadata]    -Owner
    No Operation

Task Metadata is an alias for Test Metadata, mirroring the implementation of Test Tags/Task Tags,
Test Setup/Task Setup and others.

Like the suite level Metadata setting, Test Metadata can be used multiple times, consists of
name and value, and supports documentation formatting capabilities. It is allowed in
suite files (.robot) and in suite initialization files (__init__.robot), but not in resource files(.resource).

Metadata names are compared case-insensitively and ignoring spaces and underscores, as
robot.model.Metadata is a normalized dictionary. [Metadata] -owner therefor removes Owner.

Initialization files and precedence

Test Tags in an initialization file applies to all tests in all child suites, recursively, and
merges them additive: with Test Tags init file tags in __init__.robot and
Test Tags test file tags in tests.robot, tests get init file, tags and test file.
The lower level does not replace the parent.

Test Metadata inherits the same way, in case of a name collision, the rule is to be additive across different names and have the following precedence for the same name:

[Metadata] in the test
  > Test Metadata in the suite file
    > Test Metadata in the nearest __init__.robot
      > Test Metadata in a parent __init__.robot

An initialization file is able to have both Metadata, which is metadata
of that directory suite itself, and Test Metadata, which is default for tests inside that suite.

Scope

In scope:

  • New Test Metadata setting and its Task Metadata alias, in suite files and in init files.
  • Recursive inheritance through initialization files, with the precedence described above.
  • [Metadata] adding to, overriding, and removing from those defaults.
  • Parsing model support: new token type and statement class, exposed via robot.api.parsing.
  • TestDefaults support so the setting works with the parser API and with init files.
  • Documentation and acceptance/unit tests.

Out of scope:

Open design decisions

  1. Precedence on name collisions. Is the precedence rule described above what we
    want? It differs from Test Tags, which is purely additive, but a dictionary leaves no
    alternative.
  2. Value on a removal row. Should [Metadata] -Owner some value be an error, or should
    the extra value be ignored? I would make it an error, because ignoring it can hide typos.
  3. Escaping. Is \-Name the way to use a literal name starting with a hyphen, consistent with
    \-tag?
  4. Removing everything. Should a test be able to drop all inherited metadata, e.g. with
    [Metadata] NONE or [Metadata] -*? NONE as with [Setup], [Teardown]
    and [Timeout], but it is problematic with e.g. a metadata name that is NONE.
  5. Pattern removal. [Tags] removal goes through TagPatterns, so -tag* and
    -NOT a OR b work. Should [Metadata] -Priorit* work too? I would say no initially:
    metadata is a dictionary with a small, known set of names, and glob support can be added later
    without breaking anything.

I can start working on this issue immediately, so we can try to bring this into RF 7.5, when the plan above is approved.

Activity

  1. pekkaklarck commented on Aug 31, 2026

    @pekkaklarck
    Member

    This looks good to me overall. I'll assign this to RF 7.6 scope.

    Comments about the design decisions:

    1. If I got it right, the idea is that higher level metadata is a base and lower level updates it using same rules as in Python when you update a dictionary? If yes, that sounds logical to me. Remember that also Test Metadata should support removing items set on higher level (and it's better to support than from the beginning unlike we did with tags).
    2. I think -Name Value should be an error. We could also consider using some special value that means that the whole item should be removed. We use string NONE (case-insensitively) in various places, but in this usage I see it possible that you'd actually want to have such a value. Perhaps using ${NONE} or something like <REMOVE> would be fine. Then again, -Name is consistent with -tag which is good.
    3. If we use -Name for removal, escaping like \-Name should work.
    4. I don't think it makes sense to support removing everything with any special syntax. See the next point, though.
    5. I don't consider pattern matching that important, but it would also be easy to implement and it would automatically support clearing all with -*. If we think it has any use, better to implement it now than to delay it later.
  2. modified the milestones: v7.5, v7.6 on Aug 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions