E2E tests in one Docker container for Jenkins

This story will guide you through the steps to setup an all-in-container solution for e2e testing.

Tim Nederhoff
Test Automation Pro
2 min readFeb 16, 2021

--

The past few years I have been struggling with different setups to manage a test environment for my e2e tests. Most important aspects are: maintainability, easy to understand (KISS), stable, and independent. So after many (partly successful) attempts, I came up with an all-in-one container setup for Docker, and integrated and controlled from Jenkins. With this setup, it eventually comes down to have an environment that resembles your local environment. I’m using Linux on my local machine, so I can even run the exact same commands as the ones in the CI environment (the Jenkins slave).

A big advantage of this setup is in the WebDriver and browser setup. Many popular testing frameworks use the Selenium (based) Webdriver. This enables you to directly control the browser, without interfering the application running in it. As a consequence, the version of the browser should match the webdriver/geckodriver executable, and should also match the version of the webdriver of your choice (e.g. seleniumjs, protractor, webdriverio, selenium-java-webdriver). To put both browser and Webdriver executable in the same Docker image, there is no problem is versions mismatch (for example, when the browser is updated meanwhile).

What are we gonna do:

  • setup Docker image
  • setup Jenkins pipeline

Setup Docker Image

In this example we use an Angular application to be tested using the Protractor framework on Firefox and Chrome browsers. Therefore we need the following to install:

  • NodeJS
  • Chrome driver executable
  • Firefox (Gecko) driver executable
  • OS libraries that the browsers depend on to run headed

As an example, see below Docker file:

Setup Jenkins Pipeline

This Docker image can easily be parameterised, so a new version based on the browser version can be build from a Jenkins job:

Go Jenkins!

Now we have a Docker image that is able to run all what also runs locally, we can use this container in your projects pipeline to run it all. for example:

Above example is based on a project that runs all locally. Meaning that compiling, running the application, possibly run any stubs, and finally run the tests. This can be achieved in Angular projects, using builders.

--

--

Tim Nederhoff
Test Automation Pro

As a Test Automation Engineer I help people in the testing field. Primarily by implementing test automation, CI/CD integration, tooling and testdata management