Gathering environment information

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 hosts to run the tests on, e.g. qa server, staging server
  • different browsers to run the tests on for web UI tests.
  • VCS branch - to test changes before they appear in master branch.

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?

It’s really simple!

Add environment parameters to a Job on Jenkins 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

Locate This project is parameterised in your build job settings and enable it.

We can create an environment variable called HOST on Jenkins side and assign the value so the tests will run for the site assigned to this HOST variable.

Env variable HOST

From now on, you can pass this environment variable to your tests using ${HOST}. Of course you need to implement a bit of a code which will take the environment variable and use it in your tests.

Set up Allure TestOps to receive env variable from Jenkins

Let’s set up Allure TestOps project settings for this environments information processing.

Env variable HOST

Using words: jump to your project Settings => Environment => Create => Add the environment variable to Key section => Select registered Environment variable from the drop-down list. That’s it!

… and run the build job again from Jenkins’ UI.

Env variable is populated to Allure

Using alternative VCS branch to run the tests

Jenkins provides the easiest way to gather information about VCS branches used for a test run:

  1. Create a new parameter in Jenkins build job and name it, e.g. BRANCH with default value master.
  2. Use the variable in the SCM parameters.

ALT TEXT

  1. In Allure TestOps project settings map BRANCH to global Branch variable.

ALT TEXT

  1. In Allure TestOps project locate the job associated with the build job on Jenkins side and click Update job from build server.

ALT TEXT

Now, you will have these parameters in Launches and you will be able to use them to trigger build jobs on Jenkins side with alternative environment.

It’s time to run your build jobs from Allure TestOps server.