How to run Magium tests inside of a Docker container
There is a little project I am working on that involves Magium, Docker, and awesome sauce. The sauce is still sitting in an underground cave, covered in salt, but there are parts of it that could have some eyes on it. The first part is that I now have a Docker container available for running Magium tests under. It uses the selenium/standalone-*
Docker containers but I intend to have support for other containers shortly. The containers have PHP, Selenium Server, and the appropriate driver installed and ready to go. It uses Xvfb to run the browser.
There are three steps to run it. (If you have some trouble, feel free to open an issue on the Magium Github issue tracker)
First, place a new Dockerfile at the base of your Magium tests. It should look like this:
FROM magium/clairvoyant-chrome-php-7.0
COPY . /magium/
Composer is installed so if you need to do this you may need to have your Dockerfile look like this:
FROM magium/clairvoyant-chrome-php-7.0
COPY . /magium/
RUN composer update -d /magium
Then you need to build your Docker image
docker build -t my-tests .
Then run it
docker run -ti -e "MAGIUM_EXEC=/magium/vendor/bin/phpunit /magium/tests" my-tests
The environment variable, specified by -e
is important. Otherwise PHPUnit will run all of the unit tests it can find in your source tree.
There you go. Quick and easy Magium test runs in Docker.