Commit e8102649 authored by Johan Vervloet's avatar Johan Vervloet


parent 51a3cd60
Pipeline #61263995 failed with stages
in 2 minutes and 1 second
# Running codeception web tests with gitlab-ci
I created this demo project because I have struggled a lot to get this working on another project I work on.
## The demo application
The application I will be testing, is a very basic vue.js application. You can see what it does by opening
the `public/index.html` page in your browser.
## Testing locally
To run the tests on your local computer, make sure you have a working [composer](
### Install the dependencies for codeception:
# run this command from the project root:
composer install
### Generate codeception actor classes:
./vendor/bin/codecept build
### Start a local webserver
E.g. the built in server of php:
php -S -t public/
### Run a selenium server
This is easy with docker:
docker run --net=host selenium/standalone-chrome
### Run the tests
./vendor/bin/codecept run acceptance
## Testing with gitlab-ci
I created a [`.gitlab-ci`-file](, and this way every time I push to my
repository, a gitlab runner [runs the web tests]( Which is very cool!
There are still some issues with this .gitlab-ci, if you know how I can improve it: let me know.
The main problem is that I had to replace the url for the appliction for the selenium server to find it. This happens in this line:
- sed -i "s/localhost:8080/$LOCAL_IP:8080/" tests/acceptance.suite.yml
The tricky part is finding out the local ip address of the container running the test script. I did it like this:
- LOCAL_IP=$(ip route get | awk -F"src " 'NR==1{split($2,a," ");print a[1]}')
But for this to work, I need iproute2 on my php container, and guess what: it wasn't there.
So I created a custom php-container which I uploaded to the [registry of the project](
It is based on the [Dockerfile]( included in the project source.
## A thing you should not try
I tried to use nginx and php-fpm containers for running the webserver for the tests, but this caused all kinds of (docker) networking issues.
So you shouldn't do that. As it turns out, PHP's built-in webserver will do the job just fine.
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment