All Projects → marmelab → Docker Parallel Phpunit Demo

marmelab / Docker Parallel Phpunit Demo

Licence: mit
How to use Docker to run PHPUnit tests in parallel
archived Archived Repository
This code is no longer maintained. Feel free to fork it, but use it at your own risks.

Running Symfony Tests In Parallel

This repository aims to reflect code published in an article on the marmelab's blog.

This is a simple Symfony2 project with 2 tests (DemoControllerTest & SecondControllerTest).

Each one simulate a lot of tests with a pause of 5 seconds.

Running these tests the normal way :

$ time phpunit -c app/

real	0m10.443s
user	0m0.379s
sys	0m0.050s

Running these tests in parallel :

$ time sh tests.sh

real	0m6.427s
user	0m0.084s
sys	0m0.100s

Why Using Docker To Run Your Tests ?

This example is not explicit, you can run these tests in parallel only with GNU Parallel.

However your tests can use a storage engine, a search index or other dependencies. In this case when you alter data in a test, this data should not be changed in other tests. Docker allows to run each test in isolated containers so other tests aren't affected.

Installation

composer install

Windows/OSX users

Docker only support Linux LXC (for now) so we should run a virtual machine :

vagrant up
vagrant ssh

cd /vagrant

Running tests

sh tests.sh
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].