diff options
author | Stas Vilchik <vilchiks@gmail.com> | 2014-12-12 15:23:01 +0100 |
---|---|---|
committer | Stas Vilchik <vilchiks@gmail.com> | 2014-12-12 15:23:01 +0100 |
commit | 874dccdff9b283901d983925f3d5c83879184cbc (patch) | |
tree | 52bef34be89553a934c9f6a5b0537f7adbc54195 | |
parent | 99290e5b07dc5105d249392af29e89b03d25f70a (diff) | |
download | sonarqube-874dccdff9b283901d983925f3d5c83879184cbc.tar.gz sonarqube-874dccdff9b283901d983925f3d5c83879184cbc.zip |
Web Tests: take a screenshot on failure
3 files changed, 22 insertions, 12 deletions
diff --git a/server/sonar-web/Gruntfile.coffee b/server/sonar-web/Gruntfile.coffee index 75826ff14c0..0c7a26c5749 100644 --- a/server/sonar-web/Gruntfile.coffee +++ b/server/sonar-web/Gruntfile.coffee @@ -305,6 +305,7 @@ module.exports = (grunt) -> options: test: true 'no-colors': true + 'fail-fast': true concise: true port: '<%= grunt.option("port") %>' src: ['<%= pkg.sources %>js/tests/e2e/tests/**/*.js'] diff --git a/server/sonar-web/src/main/js/tests/e2e/lib.js b/server/sonar-web/src/main/js/tests/e2e/lib.js index 0b23b65f842..51b9ae36aac 100644 --- a/server/sonar-web/src/main/js/tests/e2e/lib.js +++ b/server/sonar-web/src/main/js/tests/e2e/lib.js @@ -9,7 +9,15 @@ var BASE_URL = 'http://localhost:' + getPort() + '/pages/', WINDOW_HEIGHT = 800; -exports.initMessages = function () { +exports.capture = function (fileName) { + if (!fileName) { + fileName = 'screenshot.png'; + } + casper.capture(fileName, { top: 0, left: 0, width: WINDOW_WIDTH, height: WINDOW_HEIGHT }); +}; + + +exports.initMessages = function (testName) { // Dump log messages casper.removeAllListeners('remote.message'); if (casper.cli.get('verbose')) { @@ -25,6 +33,16 @@ exports.initMessages = function () { this.echo('Error: ' + msg, 'ERROR'); }); } + + casper.on('step.error', function () { + var fileName = (testName || 'screenshot') + '.png'; + exports.capture(fileName); + }); + + casper.on('waitFor.timeout', function () { + var fileName = (testName || 'screenshot') + '.png'; + exports.capture(fileName); + }); }; @@ -61,7 +79,6 @@ exports.mockRequest = mockRequest; exports.mockRequestFromFile = function (url, fileName, options) { - console.log('mock request "' + url + '" from file "' + fs.workingDirectory + fs.separator + fileName + '"'); var response = fs.read(fileName); return mockRequest(url, response, options); }; @@ -91,14 +108,6 @@ exports.setDefaultViewport = function () { }; -exports.capture = function (fileName) { - if (!fileName) { - fileName = 'screenshot.png'; - } - casper.capture(fileName, { top: 0, left: 0, width: WINDOW_WIDTH, height: WINDOW_HEIGHT }); -}; - - exports.waitForElementCount = function (selector, count, callback) { return casper.waitFor(function () { return casper.evaluate(function (selector, count) { diff --git a/server/sonar-web/src/main/js/tests/e2e/tests/issues-page-should-ignore-sorting-in-url.js b/server/sonar-web/src/main/js/tests/e2e/tests/issues-page-should-ignore-sorting-in-url.js index fea17a0f83c..9144e9ef19f 100644 --- a/server/sonar-web/src/main/js/tests/e2e/tests/issues-page-should-ignore-sorting-in-url.js +++ b/server/sonar-web/src/main/js/tests/e2e/tests/issues-page-should-ignore-sorting-in-url.js @@ -2,7 +2,7 @@ var lib = require('../lib'), testName = lib.testName('Issues'); -lib.initMessages(); +lib.initMessages('issues-page-should-ignore-sorting-in-url'); lib.changeWorkingDirectory('issues-page-should-ignore-sorting-in-url'); @@ -18,7 +18,7 @@ casper.test.begin('issues-page-should-ignore-sorting-in-url', function (test) { }) .then(function () { - casper.waitForSelector('.facet[data-value=BLOCKER]'); + casper.waitForSelector('.facet[data-value=BLOCKER1]'); }) .then(function () { |