reportportal / agent-Python-RobotFramework

Robot Framework integration for Report Portal
Apache License 2.0
59 stars 32 forks source link

Native config file to setup execution parameters #122

Closed notfounnd closed 2 years ago

notfounnd commented 3 years ago

Issue Description

Currently it is necessary to insert in the command "robot" all the parameters to configure the execution with the robot framework listener.

Solution Description

As a user I would like to keep the configuration of these parameters inside a file (json, txt, py...) So that I don't have to enter all the information in the execution command

Additional information

This idea came after checking the ReportPortal integration model with tools in other technologies (ruby, js, java, .net). The reading of parameters normally takes place through a configuration file.

This usage model facilitates the usability of the resource and simplifies the maintenance of these configurations.

iivanou commented 3 years ago

@notfounnd You can put all of these parameters into the variable files: https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#variable-files. Robot supports three different formats.

notfounnd commented 3 years ago

@iivanou did you would have an variables.py example file used with --variable file argument?

HardNorth commented 3 years ago

@notfounnd https://github.com/reportportal/examples-python/blob/master/robotframework/run-variables-file.sh BTW you need PyYAML to store variables in YAML.

notfounnd commented 3 years ago

Thank you so much for the help @iivanou and @HardNorth! I followed the example of this project and it worked as expected.

After implementing according to the example model, I was also able to understand and do it with native Python.

Project:

poc-robot-framework
  ├── pages
  ├── resources
  ├── settings
  ├── tests
  ├── .gitignore
  ├── robotrun.sh
  └── variables.py

File robotrun.sh start execution like the repository example.

File variables.py implements native python. It has the following structure:

def get_variables():
    variables = {
        "RP_UUID": "5f9714b1-160f-XXXX-XXXX-cb7c32d5XXXX",
        "RP_ENDPOINT": "http://localhost:8080",
        "RP_LAUNCH": "POC_ROBOT_FRAMEWORK",
        "RP_PROJECT": "poc_robot_framework"
    }
    return variables

Finally, execution can be performed using the following command:

robot -d ./results --listener robotframework_reportportal.listener -V variables.py ./tests
HardNorth commented 2 years ago

Answered