Docker Tip #71: Running Local and CI Tests for Your Applications

Running tests locally or inside a continuous integration server share the same workflow. This is one reason why Docker is so useful.
When it comes to developing your application, a typical workflow would be:
docker-compose upto bring everything up- Start hacking away on your code
docker-compose exec web testto run your tests in awebservice
That exec command will run your tests inside of the existing web service.
This avoids the overhead of having to spin up an extra web container just to
run your tests.
Depending on what code editor you use, you might even set things up so that when you press a key, it runs a variant of that exec command to limit tests for the specific file you’re working on, or even a specific function based on where your cursor is.
When it comes time to testing your app in CI, a typical workflow would be:
docker-compose up -dto bring everything up in the backgrounddocker-compose exec web testto run your tests in awebservice
Nothing changed other than we didn’t edit any code in between. From this point, you could do whatever you need to do when your tests pass, such as building production ready Docker images and pushing them to a Docker registry.