Gathering the information about test environment
For what?
It is quite rare situation when tests run without any parameters which define different conditions to run the tests. These conditions could be for instance:
- different browsers to run the tests on for web UI tests.
- different hosts to run the tests on, e.g. qa server, staging server.
- VCS branch - to test changes before they appear in master branch. It’s a bit tricky for gitlab.
When Allure TestOps gathered this information, it will allow you starting the build jobs with the environment of your choice right from its UI.
How?
Let’s find out…
Add environment parameters to a Job on Circle CI side
Now, say by default our test will check the production site using its API but from time to time we might want to test QA version of the site or staging or whatever version we could have. This requires tests’ parameterisation.
Adding parameters
- In your Circle CI project start editing the config of your pipeline Settings => CI/CD and
- Locate
environment
section. - Add an environment variable (e.g.
TESTING_HOST
)
environment:
#<snip>
TESTING_HOST: https://qa.somehost.xyz
#<snip>
- Include this variable in your tests
- run: ./allurectl watch -- ./gradlew test -Ptest_host=${TESTING_HOST}
The next steps is the configuration of Allure TestOps - you must explicitly mark the variables which Allure TestOps needs to process.
Set up Allure TestOps to receive environment variable from Circle CI
Administration section of Allure TestOps
Let’s set up Allure TestOps project settings for this environments information processing.
If you haven’t registered the environment variable yet, then first you need…
- Invoke your main user’s menu.
- Go to the Administration section of Allure TestOps (you need admin’s rights).
- Go to the Environment section.
- Introduce a new variable by clicking +Create
You just need to provide the name/label for the global variable. In our example it’s Host, this variable will contain the URL of the host where your tests will be running.
Project’s Environment section
- Jump to your project Settings.
- Jump to the Environment section.
- Click Create.
- Add the environment variable (
TESTING_HOST
) to Key section and Select registered Environment (Host
) from the drop-down list. - Submit the changes.
That’s it!
… and run the build job again from Gitlab’s UI.
Now, it’s time to run your build jobs from Allure TestOps server.