Answer a question

I am developing some Robot Framework API tests.

The end goal is to have a set of tests added to our project so that every time a developer builds and deploys the project with Jenkins the tests run automatically to check if everything is functioning properly.

I want to make the tests check which environment they are being deployed on (Dev 1, 2, 3/Test/Accept) and automatically fill that in as a variable. For example https://${VARIABLE}.companyname.com/service/api should turn into https://portal-01.dev.companyname.com/service/api when deployed on Dev server 1. That way there can be 1 test set for everything without having to maintain a set for every environment.

We use Consul to manage our services and Ansible for the deployment so it should be possible to get a tag either from there or from Jenkins to fill in this variable.

Does anyone know how I can get this tag and put this variable into Robot Framework?

Answers

Using variable files you can separate your test logic from the required test data. This is the preferred way, instead of storing your environment data in the same file as your test logic.

The information can be dynamically generated using a Python or Java class or plain text through (yaml). These files can then be added to your test run through the commandline:

robot --variablefile myvariables.py mytest.robot
robot --variablefile myvariables.yaml mytest.robot
Logo

CI/CD社区为您提供最前沿的新闻资讯和知识内容

更多推荐