Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access Metadata set from cmd line in RobotFramework

In case of setting Metadata for top-level test suites with the --metadata command line option (as described here) I don't see any working variants of accessing Metadata items (via &{SUITE METADATA} automatic variable, as mentioned here) within the Test Suite.

Namely, when running

pybot --metadata prettyMetaName:someMetaValue ...

trying to get key prettyMetaName in the test suite setup with &{SUITE METADATA}[prettyMetaName], I get this error:

Parent suite setup failed:
Dictionary variable '&{SUITE METADATA}' has no key 'prettyMetaName'.

More detailed part of the test:

*** Keywords ***
Custom Setup
    Log     &{SUITE METADATA}[prettyMetaName]     level=WARN

*** Settings ***
Suite Setup     Custom Setup

But if I try to get metadata via python library Listener API, I'm getting the valid result.

On the other hand, in case of explicit declaring Metadata in the Settings section, everything works as expected.

I'm using Robot 3.0.4.

like image 476
kenichi Avatar asked Mar 28 '26 06:03

kenichi


1 Answers

I think you need an __init__.robot file in the root folder of your robot project with the following content.

*** Settings ***
Suite Setup       Store Top Suite Metadata


*** Keywords ***
Store Top Suite Metadata
    Set Suite Variable   ${TOP SUITE METADATA}    ${SUITE METADATA}    children=True

Then you can use the ${TOP SUITE METADATA} variable everywhere else to get access to the metadata set by command line arguments.

like image 80
Bence Kaulics Avatar answered Mar 31 '26 13:03

Bence Kaulics