ppodgorsek / docker-robot-framework

Robot Framework in Docker
https://cloud.docker.com/repository/docker/ppodgorsek/robot-framework
MIT License
347 stars 240 forks source link

Sharing Variables, Libraries and keywords #488

Closed OrrinGradwell closed 5 months ago

OrrinGradwell commented 5 months ago

Is your feature request related to a problem? Please describe. Yes.

The way wa have set up tests are to have as much as possible reusable code. This is done by having keywords.resource, varibales.resource and libraries.resource files created in a "core" dir on the project root. All our tests use those files as a resource and we can can call them as such..

Example being our login...

We are a Saas company so our logins allow different areas to the same site, so sharing the login. Same goes for variables that we just change at runtime...

Describe the solution you'd like As we link -v ${PWD}/variables:/opt/robotframework/variables:Z Simply being able to do that on a wider scale will work: -v ${PWD}/core/variables:/opt/robotframework/variables:Z -v ${PWD}/core/keywords:/opt/robotframework/keywords:Z \ -v ${PWD}/core/libraries:/opt/robotframework/libraries:Z \

"core" in this case is simply our naming convention. It should be noted that each dir has multiple resource files in them and they should all be used.

OrrinGradwell commented 5 months ago

As per the robotframework documentation, we loosely follow the following structure

my_project
    tests
        frontend
            suiteA.robot
        backend
            suiteB.robot
    resources
        general.resource
        auth
            login.resource
            totp.py

https://docs.robotframework.org/docs/examples/project_structure

OrrinGradwell commented 5 months ago

I found a solution to this...

Adding "-v ${PWD}/resources:/opt/robotframework/resources:Z \" to the docker run command and then changing the tests too look for it from root dir like "Resource ../resources/default_variables.resource" solved it for me.