From c50acff6d8ae92c49d194b9d39564c06f3fd550f Mon Sep 17 00:00:00 2001 From: Michael Krotscheck Date: Mon, 17 Aug 2015 12:03:21 -0700 Subject: [PATCH] Added karma threshold reporting & failure This patch adds unit test coverage threshold reporting, adding statement, branch, function, and line coverage to the console output in infra, and failing the build if the threshold has not been met. The threshold values have been set to the current observed coverage values - future patches should update this up as coverage improves. Closes-Bug: 1487109 Change-Id: Ie83ebf5d976b3538e3528787b05de3e83df18af8 --- horizon/karma.conf.js | 13 +++++++++++-- openstack_dashboard/karma.conf.js | 13 +++++++++++-- package.json | 1 + 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/horizon/karma.conf.js b/horizon/karma.conf.js index 93752feb57..bbcfb15543 100644 --- a/horizon/karma.conf.js +++ b/horizon/karma.conf.js @@ -133,18 +133,27 @@ module.exports = function (config) { exitOnResourceError: true }, - reporters: ['progress', 'coverage'], + reporters: ['progress', 'coverage', 'threshold'], plugins: [ 'karma-phantomjs-launcher', 'karma-jasmine', 'karma-ng-html2js-preprocessor', - 'karma-coverage' + 'karma-coverage', + 'karma-threshold-reporter' ], coverageReporter: { type: 'html', dir: '../.coverage-karma/' + }, + + // Coverage threshold values. + thresholdReporter: { + statements: 86, // target 100 + branches: 68, // target 100 + functions: 87, // target 100 + lines: 87 // target 100 } }); }; diff --git a/openstack_dashboard/karma.conf.js b/openstack_dashboard/karma.conf.js index 27ddfb49e8..9cc623be33 100644 --- a/openstack_dashboard/karma.conf.js +++ b/openstack_dashboard/karma.conf.js @@ -143,18 +143,27 @@ module.exports = function (config) { exitOnResourceError: true }, - reporters: ['progress', 'coverage'], + reporters: ['progress', 'coverage', 'threshold'], plugins: [ 'karma-phantomjs-launcher', 'karma-jasmine', 'karma-ng-html2js-preprocessor', - 'karma-coverage' + 'karma-coverage', + 'karma-threshold-reporter' ], coverageReporter: { type: 'html', dir: '../.coverage-karma/' + }, + + // Coverage threshold values. + thresholdReporter: { + statements: 93, // target 100 + branches: 93, // target 100 + functions: 93, // target 100 + lines: 93 // target 100 } }); }; diff --git a/package.json b/package.json index 20ecf2f53c..d7f8091424 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "karma-jasmine": "0.3.5", "karma-ng-html2js-preprocessor": "0.1.2", "karma-phantomjs-launcher": "0.2.0", + "karma-threshold-reporter": "0.1.15", "phantomjs": "1.9.17" }, "scripts": {