0

I have a project for which I am using Teamcity to automate deployment, and I would also like to automate testing.

It is an angular frontend, and we have some protractor tests.

I would like to run these tests as one of the steps in our build configuration.

I would like to have these tests run inside a docker container instead of the teamcity agent.

I am able to run other steps using docker containers, so I have teamcity and docker working as expected.

My main problem here is being able to run this within the docker container. I would like to have a container that would be able to run without having to rely on external containers, however it seems that the containers I have found and tried using rely on an external selenium instance. Either I am misunderstanding how this should run, or I would like a self contained container to run the tests and drop dead afterwards.

Bear in mind that these tests can be run locally in our development workstations, with selenium and protractor running locally. I would like to achieve the same through a docker container, without that container having to rely on an external selenium server instance.

I have tried the following docker containers:

When I try to run the tests, they both complain selenium server could not be found.

This is my protractor configuration file:

// conf.js
var spec_files = "tests/*.specs.js";
exports.config = {
  framework: 'jasmine',
  seleniumAddress: 'http://localhost:4444/wd/hub',
  specs: [spec_files],
  multiCapabilities: [{
    browserName: 'chrome'
  }],
  baseUrl: 'test',
  restartBrowserBetweenTests: true
}

The baseUrl parameter is fed into protractor with the following command:

protractor conf.js --baseUrl="http://[Replaced with Environment domain name]:8080"

What am I missing here?

0

I have been able to figure out how to get everything to work.

Let's start from the beginning:

Changes to config file

  1. Remove the selenium server settings (the docker container starts one on every run, and uses that automatically)
  2. Add 'useAllAngular2AppRoots' otherwise the tests will all fail

The resulting config file will be something like this (ignore the params section, that is just an object with additional parameters you can inject into your tests):

// conf.js
var spec_files = "tests/*.specs.js";
exports.config = {
  framework: 'jasmine',
  specs: [spec_files],
  useAllAngular2AppRoots: true,
  multiCapabilities: [{
    browserName: 'chrome'
  }],
  restartBrowserBetweenTests: true,
  params: {
    sleepTime: 0
  }
}

Setting up the build step in teamcity

Usually when I want to run a build step I do it in a docker container, and execute command line steps inside that container.

To get this to run I could not do this, as we need to inject a few parameters at the end of the run command, so you need to create a docker command, looking like this:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.