BLOG

Verba volant, scripta manent.

Spoken words fly away, written words remain

Serenity Environments Configuration

| Comments

Real, production-grade and automated acceptance tests on top of Selenium are running on different environments.

If you are using Serenity you will find here a useful tip - how to set up a multi environment configuration.

Context

Recently I discovered the powerful Java framework for writing acceptance tests on top of Selenium, which is called Serenity.

One of the basic requirements we have is to run your tests on different environments:

  • Developer will run test on the local machine
  • Jenkins will run your acceptance tests on a remote machine
  • Sometimes you will need to run your tests on production (as a fastest way to guarantee the non-regression after release)

Multi environment configuration

So you need to tell the serenity framework where to find those config. We have started to using Spring profiles to manage this configuration. Hopefully Serenity supports Spring. But we faced the problem of handling 2 different configs: 1. Serenity.properties 2. Spring-based config with localhost.properties, staging.properties, production.properties

Config with Spring was hard, non intuitive and error-prone.

Solution - serenity.conf file

The solution is to use the special config file natively understandable by Serenity framework - serenity.conf

1
2
3
4
5
6
7
8
9
10
11
environments {
    localhost {
        webdriver.base.url = "http://localhost:8080/"
    }
    staging {
        webdriver.base.url = "http://staging.devatlant.com"
    }
    prod {
        webdriver.base.url = "http://my.super.production.com"
    }
}

Unfortunately this very useful feature is not yet documented on the official project page, I have found it here

Serenity version is 2.0.30 or higher

This feature is available for you from 2.0.30. Guys from Serenity project releases often (369 releases! at date of the 22 March 2019 ), so keep in mind to regularly updating your maven dependency from official GitHub release page

Run maven with environment name

1
mvn run -Denvironment=staging

Comments