From 9ced677ec7547ae23aea589983aa13c1d50d4fec Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Mon, 4 Jul 2016 06:57:00 +0100 Subject: [PATCH] Run tests on multiple CPU cores MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We can make the tests run slightly faster by parallelizing them across multiple CPU cores: - from some casual testing locally, 2 cores gives the optimum speedup - Travis container-based builds have 2 CPU cores available[1] - the net gain is about 20%, or 2 seconds - unfortunately we can’t do this on the API because each test is still using the same instance of the database 1. https://docs.travis-ci.com/user/ci-environment/#Virtualization-environments --- requirements_for_test.txt | 1 + scripts/run_tests.sh | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/requirements_for_test.txt b/requirements_for_test.txt index 3f3644dd7..ac3893c5c 100644 --- a/requirements_for_test.txt +++ b/requirements_for_test.txt @@ -3,6 +3,7 @@ pep8==1.7.0 pytest==2.9.1 pytest-mock==0.11.0 pytest-cov==2.2.1 +pytest-xdist==1.14 coveralls==1.1 moto==0.4.23 httpretty==0.8.14 diff --git a/scripts/run_tests.sh b/scripts/run_tests.sh index 03e31b9b8..d010edfb9 100755 --- a/scripts/run_tests.sh +++ b/scripts/run_tests.sh @@ -33,7 +33,7 @@ display_result $? 2 "Front end code style check" export NOTIFY_ADMIN_ENVIRONMENT='config.Test' ## Code coverage -py.test --cov=app --cov-report=term-missing tests/ +py.test -n2 --cov=app --cov-report=term-missing tests/ display_result $? 3 "Code coverage" #py.test -v