From 5c4de3d13df6d65580405b8e40070a5e1bf7f873 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Thu, 7 Apr 2016 10:28:29 +0100 Subject: [PATCH] Add code coverage - generates a code coverage report - triggers Coveralls on every Travis build - adds a badge to the README --- .coveralls.yml | 1 + .travis.yml | 1 + README.md | 1 + requirements_for_test.txt | 2 ++ scripts/run_tests.sh | 4 ++-- 5 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 .coveralls.yml diff --git a/.coveralls.yml b/.coveralls.yml new file mode 100644 index 000000000..7008d5a9b --- /dev/null +++ b/.coveralls.yml @@ -0,0 +1 @@ +service_name: travis-pro \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 030da3e0c..97895ac75 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,6 +11,7 @@ install: - npm rebuild node-sass - pip install -r requirements_for_test.txt after_success: +- coveralls - ./scripts/trigger-dependent-build.sh script: - npm run build diff --git a/README.md b/README.md index a10f52496..450fee072 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ [![Build Status](https://travis-ci.org/alphagov/notifications-admin.svg)](https://travis-ci.org/alphagov/notifications-admin) [![Requirements Status](https://requires.io/github/alphagov/notifications-admin/requirements.svg?branch=master)](https://requires.io/github/alphagov/notifications-admin/requirements/?branch=master) +[![Coverage Status](https://coveralls.io/repos/alphagov/notifications-admin/badge.svg?branch=master&service=github)](https://coveralls.io/github/alphagov/notifications-admin?branch=master) [![Deploy to staging](https://notify-build-monitor.herokuapp.com/deploys/notifications-admin/master...staging.svg?prefix=Deploy%20to)](https://github.com/alphagov/notifications-admin/compare/staging...master?expand=1&title=Deploy%20to%20staging) [![Deploy to live](https://notify-build-monitor.herokuapp.com/deploys/notifications-admin/staging...live.svg?prefix=Deploy%20to)](https://github.com/alphagov/notifications-admin/compare/live...staging?expand=1&title=Deploy%20to%20live) diff --git a/requirements_for_test.txt b/requirements_for_test.txt index 3fe7eb737..0cefcfa0e 100644 --- a/requirements_for_test.txt +++ b/requirements_for_test.txt @@ -2,6 +2,8 @@ pep8==1.5.7 pytest==2.8.1 pytest-mock==0.8.1 +pytest-cov==2.2.1 +coveralls==1.1 moto==0.4.19 httpretty==0.8.10 beautifulsoup4==4.4.1 diff --git a/scripts/run_tests.sh b/scripts/run_tests.sh index d2a2f4865..93b022691 100755 --- a/scripts/run_tests.sh +++ b/scripts/run_tests.sh @@ -31,8 +31,8 @@ npm test display_result $? 2 "Front end code style check" ## Code coverage -#py.test --cov=app tests/ -#display_result $? 3 "Code coverage" +py.test --cov=app --cov-report=term-missing tests/ +display_result $? 3 "Code coverage" export NOTIFY_ADMIN_ENVIRONMENT='config.Test' py.test -v