Repository navigation
Test Metadata setting to set default metadata for tests #5769
Description
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
Settingssection similarly as other settings have. We could introduce a separate
Test Metadata(andTask Metadata) setting that would specify the default metadata and
[Metadata]could then add new and modify values similarly as[Tags]can modify tags set
withTest Tags. [...] The only design decision I see is agreeing on syntax how to remove
metadata. Probably using-Namelike you can use-tagwith 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 OperationTask 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 Metadatasetting and itsTask Metadataalias, 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. TestDefaultssupport so the setting works with the parser API and with init files.- Documentation and acceptance/unit tests.
Out of scope:
- Specifying metadata without the
Metadata/[Metadata]setting, e.g.[Issue] 4409(Support specifying suite, test and keyword metadata as custom settings #5637). - Keyword level metadata (Keyword metadata #5627).
- A command line option for setting default test metadata, and any
--settag/--removetags
equivalent. - A
Default Metadatacounterpart toDefault Tags, which is deprecated anyway.
Open design decisions
- Precedence on name collisions. Is the precedence rule described above what we
want? It differs fromTest Tags, which is purely additive, but a dictionary leaves no
alternative. - Value on a removal row. Should
[Metadata] -Owner some valuebe an error, or should
the extra value be ignored? I would make it an error, because ignoring it can hide typos. - Escaping. Is
\-Namethe way to use a literal name starting with a hyphen, consistent with
\-tag? - Removing everything. Should a test be able to drop all inherited metadata, e.g. with
[Metadata] NONEor[Metadata] -*?NONEas with[Setup],[Teardown]
and[Timeout], but it is problematic with e.g. a metadata name that isNONE. - Pattern removal.
[Tags]removal goes throughTagPatterns, so-tag*and
-NOT a OR bwork. 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
pekkaklarck commentedon Aug 31, 2026
This looks good to me overall. I'll assign this to RF 7.6 scope.
Comments about the design decisions:
Test Metadatashould support removing items set on higher level (and it's better to support than from the beginning unlike we did with tags).-Name Valueshould be an error. We could also consider using some special value that means that the whole item should be removed. We use stringNONE(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,-Nameis consistent with-tagwhich is good.-Namefor removal, escaping like\-Nameshould work.-*. If we think it has any use, better to implement it now than to delay it later.Add Test Metadata setting for default test metadata