mirror of
https://github.com/SonarSource/sonarqube.git
synced 2024-08-08 03:05:57 +02:00
generate js coverage report from casperjs tests
This commit is contained in:
parent
6c41cba0d2
commit
2d7eac92dc
8
pom.xml
8
pom.xml
@ -85,6 +85,7 @@
|
||||
<skipBatchTests>false</skipBatchTests>
|
||||
<skipServerTests>false</skipServerTests>
|
||||
<skipWebTests>false</skipWebTests>
|
||||
<jsCoverage>nocoverage</jsCoverage>
|
||||
|
||||
<version.maven-license.plugin>1.9.0</version.maven-license.plugin>
|
||||
<skipSanityChecks>false</skipSanityChecks>
|
||||
@ -1550,6 +1551,13 @@
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
|
||||
<profile>
|
||||
<id>analysis</id>
|
||||
<properties>
|
||||
<jsCoverage>coverage</jsCoverage>
|
||||
</properties>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
</project>
|
||||
|
@ -1,6 +1,8 @@
|
||||
module.exports = (grunt) ->
|
||||
require('jit-grunt')(grunt, {
|
||||
express: 'grunt-express-server'
|
||||
unzip: 'grunt-zip'
|
||||
replace: 'grunt-text-replace'
|
||||
});
|
||||
|
||||
pkg = grunt.file.readJSON('package.json')
|
||||
@ -325,12 +327,16 @@ module.exports = (grunt) ->
|
||||
express:
|
||||
test:
|
||||
options:
|
||||
script: '<%= pkg.sources %>js/tests/e2e/server.js'
|
||||
script: 'src/test/server.js'
|
||||
port: expressPort
|
||||
testCoverage:
|
||||
options:
|
||||
script: 'src/test/server-coverage.js'
|
||||
port: expressPort
|
||||
dev:
|
||||
options:
|
||||
background: false
|
||||
script: '<%= pkg.sources %>js/tests/e2e/server.js'
|
||||
script: 'src/test/server.js'
|
||||
|
||||
|
||||
casper:
|
||||
@ -342,14 +348,22 @@ module.exports = (grunt) ->
|
||||
concise: true
|
||||
parallel: true
|
||||
port: expressPort
|
||||
src: ['<%= pkg.sources %>js/tests/e2e/tests/**/*.js']
|
||||
src: ['src/test/js/**/*.js']
|
||||
testCoverage:
|
||||
options:
|
||||
test: true
|
||||
'no-colors': true
|
||||
'fail-fast': true
|
||||
concise: true
|
||||
port: expressPort
|
||||
src: ['src/test/js/**/*.js']
|
||||
single:
|
||||
options:
|
||||
test: true
|
||||
verbose: true
|
||||
'fail-fast': true
|
||||
port: expressPort
|
||||
src: ['<%= pkg.sources %>js/tests/e2e/tests/<%= grunt.option("spec") %>-spec.js']
|
||||
src: ['src/test/js/<%= grunt.option("spec") %>-spec.js']
|
||||
testfile:
|
||||
options:
|
||||
test: true
|
||||
@ -370,6 +384,32 @@ module.exports = (grunt) ->
|
||||
]
|
||||
|
||||
|
||||
curl:
|
||||
resetCoverage:
|
||||
src:
|
||||
url: 'http://localhost:' + expressPort + '/coverage/reset'
|
||||
method: 'POST'
|
||||
dest: 'target/reset_coverage.dump'
|
||||
|
||||
downloadCoverage:
|
||||
src: 'http://localhost:' + expressPort + '/coverage/download'
|
||||
dest: 'target/coverage.zip'
|
||||
|
||||
|
||||
unzip:
|
||||
'target/js-coverage': 'target/coverage.zip'
|
||||
|
||||
|
||||
replace:
|
||||
lcov:
|
||||
src: 'target/js-coverage/lcov.info'
|
||||
dest: 'target/js-coverage/lcov.info'
|
||||
replacements: [{
|
||||
from: '/webapp'
|
||||
to: ''
|
||||
}]
|
||||
|
||||
|
||||
jshint:
|
||||
dev:
|
||||
src: [
|
||||
@ -422,6 +462,9 @@ module.exports = (grunt) ->
|
||||
grunt.registerTask 'test',
|
||||
['dev', 'express:test', 'casper:test']
|
||||
|
||||
grunt.registerTask 'testCoverage',
|
||||
['dev', 'express:testCoverage', 'curl:resetCoverage', 'casper:testCoverage', 'curl:downloadCoverage', 'unzip', 'replace:lcov']
|
||||
|
||||
grunt.registerTask 'single',
|
||||
['dev', 'express:test', 'casper:single']
|
||||
|
||||
@ -429,8 +472,11 @@ module.exports = (grunt) ->
|
||||
['dev', 'express:test', 'casper:testfile']
|
||||
|
||||
# tasks used by Maven build (see pom.xml)
|
||||
grunt.registerTask 'maven-build-skip-tests-true',
|
||||
grunt.registerTask 'maven-build-skip-tests-true-nocoverage',
|
||||
['build']
|
||||
|
||||
grunt.registerTask 'maven-build-skip-tests-false',
|
||||
grunt.registerTask 'maven-build-skip-tests-false-nocoverage',
|
||||
['test', 'build']
|
||||
|
||||
grunt.registerTask 'maven-build-skip-tests-false-coverage',
|
||||
['testCoverage', 'build']
|
||||
|
@ -19,8 +19,13 @@
|
||||
"grunt-contrib-uglify": "0.4.0",
|
||||
"grunt-contrib-watch": "0.5.3",
|
||||
"grunt-css-url-rewrite": "0.3.5",
|
||||
"grunt-curl": "2.1.0",
|
||||
"grunt-express-server": "0.4.17",
|
||||
"grunt-text-replace": "0.4.0",
|
||||
"grunt-uglify-parallel": "0.0.1",
|
||||
"grunt-zip": "0.16.2",
|
||||
"istanbul": "0.3.5",
|
||||
"istanbul-middleware": "0.2.0",
|
||||
"jade": "1.4.2",
|
||||
"jit-grunt": "0.9.1",
|
||||
"phantomjs": "1.9.7-12",
|
||||
|
@ -15,6 +15,7 @@
|
||||
<!-- self-analysis -->
|
||||
<sonar.sources>src/main/js,src/main/coffee,src/main/hbs,src/main/less</sonar.sources>
|
||||
<sonar.exclusions>src/main/js/third-party/**/*,src/main/js/require.js,src/main/js/tests/**/*</sonar.exclusions>
|
||||
<sonar.javascript.lcov.reportPath>target/js-coverage/lcov.info</sonar.javascript.lcov.reportPath>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
@ -153,7 +154,7 @@
|
||||
<goal>grunt</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<arguments>maven-build-skip-tests-${skipWebTests} --port=${jsTestPort} --no-color</arguments>
|
||||
<arguments>maven-build-skip-tests-${skipWebTests}-${jsCoverage} --port=${jsTestPort} --no-color</arguments>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
|
@ -1,26 +0,0 @@
|
||||
html
|
||||
head
|
||||
meta(http-equiv='Content-Type', content='text/html; charset=UTF-8')
|
||||
link(href='/css/sonar.css', rel='stylesheet', media='all')
|
||||
script(src='/js/sonar.js')
|
||||
script(src='/js/third-party/jquery.mockjax.js')
|
||||
script.
|
||||
var baseUrl = '';
|
||||
var $j = jQuery.noConflict();
|
||||
window.suppressTranslationWarnings = true;
|
||||
jQuery.mockjaxSettings.contentType = 'text/json';
|
||||
jQuery.mockjaxSettings.responseTime = 50;
|
||||
jQuery.mockjaxSettings.throwUnmocked = true;
|
||||
$j(document).ready(function () { $j('.open-modal').modal(); });
|
||||
window.waitForMocks = function (app) {
|
||||
var x = setInterval(function () {
|
||||
jQuery.get('/api/l10n/index').done(function () {
|
||||
clearInterval(x);
|
||||
require([app]);
|
||||
});
|
||||
}, 500);
|
||||
}
|
||||
block header
|
||||
body
|
||||
#body
|
||||
block body
|
@ -78,6 +78,10 @@ casper.test.begin('coding-rules-page-active-severity-facet', 7, function (test)
|
||||
test.assertExists('.search-navigator-facet-box-forbidden[data-property="active_severities"]');
|
||||
})
|
||||
|
||||
.then(function () {
|
||||
lib.sendCoverage();
|
||||
})
|
||||
|
||||
.run(function () {
|
||||
test.done();
|
||||
});
|
@ -58,6 +58,10 @@ casper.test.begin('coding-rules-page-available-since', 2, function (test) {
|
||||
test.assertSelectorContains('#coding-rules-total', '101');
|
||||
})
|
||||
|
||||
.then(function () {
|
||||
lib.sendCoverage();
|
||||
})
|
||||
|
||||
.run(function () {
|
||||
test.done();
|
||||
});
|
@ -101,6 +101,10 @@ casper.test.begin('coding-rules-page-inheritance-facet', 11, function (test) {
|
||||
test.assertExists('.search-navigator-facet-box-forbidden[data-property="inheritance"]');
|
||||
})
|
||||
|
||||
.then(function () {
|
||||
lib.sendCoverage();
|
||||
})
|
||||
|
||||
.run(function () {
|
||||
test.done();
|
||||
});
|
@ -58,6 +58,10 @@ casper.test.begin('coding-rules-page-no-available-profiles-for-activation', 2, f
|
||||
test.assertExists('.modal .message-notice');
|
||||
})
|
||||
|
||||
.then(function () {
|
||||
lib.sendCoverage();
|
||||
})
|
||||
|
||||
.run(function () {
|
||||
test.done();
|
||||
});
|
@ -73,6 +73,10 @@ casper.test.begin('coding-rules-page-quality-profile-facet', 6, function (test)
|
||||
test.assertSelectorContains('#coding-rules-total', '609');
|
||||
})
|
||||
|
||||
.then(function () {
|
||||
lib.sendCoverage();
|
||||
})
|
||||
|
||||
.run(function () {
|
||||
test.done();
|
||||
});
|
@ -63,6 +63,10 @@ casper.test.begin('coding-rules-page-query-facet', 3, function (test) {
|
||||
test.assertSelectorContains('#coding-rules-total', '609');
|
||||
})
|
||||
|
||||
.then(function () {
|
||||
lib.sendCoverage();
|
||||
})
|
||||
|
||||
.run(function () {
|
||||
test.done();
|
||||
});
|
@ -51,6 +51,10 @@ casper.test.begin('coding-rules-page-rule-permalink', 1, function (test) {
|
||||
test.assertExists('a[href="/coding_rules#rule_key=squid%3AS1181"]');
|
||||
})
|
||||
|
||||
.then(function () {
|
||||
lib.sendCoverage();
|
||||
})
|
||||
|
||||
.run(function () {
|
||||
test.done();
|
||||
});
|
@ -69,6 +69,10 @@ casper.test.begin('coding-rules-page-should-activate-profile', 5, function (test
|
||||
test.assertExists('.coding-rules-detail-quality-profile-deactivate');
|
||||
})
|
||||
|
||||
.then(function () {
|
||||
lib.sendCoverage();
|
||||
})
|
||||
|
||||
.run(function () {
|
||||
test.done();
|
||||
});
|
@ -70,6 +70,10 @@ casper.test.begin('coding-rules-page-should-delete-create-rules', 2, function (t
|
||||
});
|
||||
})
|
||||
|
||||
.then(function () {
|
||||
lib.sendCoverage();
|
||||
})
|
||||
|
||||
.run(function () {
|
||||
test.done();
|
||||
});
|
@ -65,6 +65,10 @@ casper.test.begin('coding-rules-page-should-delete-manual-rules', 3, function (t
|
||||
test.assertSelectorContains('.coding-rules-detail-description', 'Manual Rule Description');
|
||||
})
|
||||
|
||||
.then(function () {
|
||||
lib.sendCoverage();
|
||||
})
|
||||
|
||||
.run(function () {
|
||||
test.done();
|
||||
});
|
@ -60,6 +60,10 @@ casper.test.begin('coding-rules-page-should-delete-custom-rules', 2, function (t
|
||||
});
|
||||
})
|
||||
|
||||
.then(function () {
|
||||
lib.sendCoverage();
|
||||
})
|
||||
|
||||
.run(function () {
|
||||
test.done();
|
||||
});
|
@ -65,6 +65,10 @@ casper.test.begin('coding-rules-page-should-delete-manual-rules', 1, function (t
|
||||
test.assertSelectorContains('#coding-rules-total', 0);
|
||||
})
|
||||
|
||||
.then(function () {
|
||||
lib.sendCoverage();
|
||||
})
|
||||
|
||||
.run(function () {
|
||||
test.done();
|
||||
});
|
@ -57,6 +57,10 @@ casper.test.begin('coding-rules-page-should-show-custom-rules', 3, function (tes
|
||||
'Do not use org.h2.util.StringUtils');
|
||||
})
|
||||
|
||||
.then(function () {
|
||||
lib.sendCoverage();
|
||||
})
|
||||
|
||||
.run(function () {
|
||||
test.done();
|
||||
});
|
@ -44,6 +44,10 @@ casper.test.begin('coding-rules-page-should-show-deprecated-label', 1, function
|
||||
test.assertSelectorContains('.coding-rule.selected', 'DEPRECATED');
|
||||
})
|
||||
|
||||
.then(function () {
|
||||
lib.sendCoverage();
|
||||
})
|
||||
|
||||
.run(function () {
|
||||
test.done();
|
||||
});
|
@ -76,6 +76,10 @@ casper.test.begin('coding-rules-page-should-show-details', 20, function (test) {
|
||||
test.assertSelectorContains('.coding-rules-detail-quality-profile-inheritance', 'Default - Top');
|
||||
})
|
||||
|
||||
.then(function () {
|
||||
lib.sendCoverage();
|
||||
})
|
||||
|
||||
.run(function () {
|
||||
test.done();
|
||||
});
|
@ -46,6 +46,10 @@ casper.test.begin('coding-rules-page-should-show-empty-list', 3, function (test)
|
||||
test.assertExists('.search-navigator-no-results');
|
||||
})
|
||||
|
||||
.then(function () {
|
||||
lib.sendCoverage();
|
||||
})
|
||||
|
||||
.run(function () {
|
||||
test.done();
|
||||
});
|
@ -44,6 +44,10 @@ casper.test.begin('coding-rules-page-should-show-facets', 1, function (test) {
|
||||
test.assertElementCount('.search-navigator-facet-box', 13);
|
||||
})
|
||||
|
||||
.then(function () {
|
||||
lib.sendCoverage();
|
||||
})
|
||||
|
||||
.run(function () {
|
||||
test.done();
|
||||
});
|
@ -56,6 +56,10 @@ casper.test.begin('coding-rules-page-should-show-rule-issues', 5, function (test
|
||||
test.assertSelectorContains('.coding-rules-most-violated-projects', '1');
|
||||
})
|
||||
|
||||
.then(function () {
|
||||
lib.sendCoverage();
|
||||
})
|
||||
|
||||
.run(function () {
|
||||
test.done();
|
||||
});
|
@ -50,6 +50,10 @@ casper.test.begin('coding-rules-page-should-show-rule', 7, function (test) {
|
||||
test.assertSelectorContains('.coding-rule.selected', 'custom-tag');
|
||||
})
|
||||
|
||||
.then(function () {
|
||||
lib.sendCoverage();
|
||||
})
|
||||
|
||||
.run(function () {
|
||||
test.done();
|
||||
});
|
@ -47,6 +47,10 @@ casper.test.begin('coding-rules-page-should-show-rules', 4, function (test) {
|
||||
test.assertSelectorContains('#coding-rules-total', '609');
|
||||
})
|
||||
|
||||
.then(function () {
|
||||
lib.sendCoverage();
|
||||
})
|
||||
|
||||
.run(function () {
|
||||
test.done();
|
||||
});
|
@ -60,6 +60,10 @@ casper.test.begin(testName('Base'), function suite(test) {
|
||||
test.assertSelectorContains('.dsm-info', 'src/main/java/com/maif/sonar/cobol/metrics/TableMetricsVisitor.java ');
|
||||
})
|
||||
|
||||
.then(function () {
|
||||
lib.sendCoverage();
|
||||
})
|
||||
|
||||
.run(function () {
|
||||
test.done();
|
||||
});
|
@ -51,6 +51,10 @@ casper.test.begin('issues-page-should-open-issue-permalink', 3, function (test)
|
||||
});
|
||||
})
|
||||
|
||||
.then(function () {
|
||||
lib.sendCoverage();
|
||||
})
|
||||
|
||||
.run(function () {
|
||||
test.done();
|
||||
});
|
@ -77,6 +77,10 @@ casper.test.begin(testName('Base'), function (test) {
|
||||
});
|
||||
})
|
||||
|
||||
.then(function () {
|
||||
lib.sendCoverage();
|
||||
})
|
||||
|
||||
.run(function () {
|
||||
test.done();
|
||||
});
|
||||
@ -115,6 +119,10 @@ casper.test.begin(testName('Issue Box', 'Check Elements'), function (test) {
|
||||
test.assertExists('.issue.selected .js-issue-show-changelog');
|
||||
})
|
||||
|
||||
.then(function () {
|
||||
lib.sendCoverage();
|
||||
})
|
||||
|
||||
.run(function () {
|
||||
test.done();
|
||||
});
|
||||
@ -156,6 +164,10 @@ casper.test.begin(testName('Issue Box', 'Tags'), function (test) {
|
||||
test.assertSelectorContains('.issue.selected .js-issue-tags', 'security, design');
|
||||
})
|
||||
|
||||
.then(function () {
|
||||
lib.sendCoverage();
|
||||
})
|
||||
|
||||
.run(function () {
|
||||
test.done();
|
||||
});
|
||||
@ -189,6 +201,10 @@ casper.test.begin(testName('Issue Box', 'Transitions'), function (test) {
|
||||
test.assertExists('.issue-action-option[data-value=falsepositive]');
|
||||
})
|
||||
|
||||
.then(function () {
|
||||
lib.sendCoverage();
|
||||
})
|
||||
|
||||
.run(function () {
|
||||
test.done();
|
||||
});
|
||||
@ -222,6 +238,10 @@ casper.test.begin(testName('File-Level Issues'), function (test) {
|
||||
});
|
||||
})
|
||||
|
||||
.then(function () {
|
||||
lib.sendCoverage();
|
||||
})
|
||||
|
||||
.run(function () {
|
||||
test.done();
|
||||
});
|
||||
@ -251,6 +271,10 @@ casper.test.begin(testName('Severity Facet'), function (test) {
|
||||
});
|
||||
})
|
||||
|
||||
.then(function () {
|
||||
lib.sendCoverage();
|
||||
})
|
||||
|
||||
.run(function () {
|
||||
test.done();
|
||||
});
|
||||
@ -282,6 +306,10 @@ casper.test.begin(testName('Bulk Change'), function (test) {
|
||||
});
|
||||
})
|
||||
|
||||
.then(function () {
|
||||
lib.sendCoverage();
|
||||
})
|
||||
|
||||
.run(function () {
|
||||
test.done();
|
||||
});
|
@ -56,6 +56,10 @@ casper.test.begin('Quality Gates', function suite (test) {
|
||||
});
|
||||
})
|
||||
|
||||
.then(function () {
|
||||
lib.sendCoverage();
|
||||
})
|
||||
|
||||
.run(function () {
|
||||
test.done();
|
||||
});
|
@ -68,6 +68,10 @@ casper.test.begin(testName('source-viewer-create-manual-issue'), function (test)
|
||||
});
|
||||
})
|
||||
|
||||
.then(function () {
|
||||
lib.sendCoverage();
|
||||
})
|
||||
|
||||
.run(function () {
|
||||
test.done();
|
||||
});
|
@ -56,6 +56,10 @@ casper.test.begin(testName('Mark as Favorite'), function (test) {
|
||||
});
|
||||
})
|
||||
|
||||
.then(function () {
|
||||
lib.sendCoverage();
|
||||
})
|
||||
|
||||
.run(function () {
|
||||
test.done();
|
||||
});
|
||||
@ -82,6 +86,10 @@ casper.test.begin(testName('Don\'t Show Favorite If Not Logged In'), function (t
|
||||
test.assertDoesntExist('.icon-not-favorite');
|
||||
})
|
||||
|
||||
.then(function () {
|
||||
lib.sendCoverage();
|
||||
})
|
||||
|
||||
.run(function () {
|
||||
test.done();
|
||||
});
|
@ -54,6 +54,10 @@ casper.test.begin(testName('Link to Raw'), function (test) {
|
||||
});
|
||||
})
|
||||
|
||||
.then(function () {
|
||||
lib.sendCoverage();
|
||||
})
|
||||
|
||||
.run(function () {
|
||||
test.done();
|
||||
});
|
@ -44,6 +44,10 @@ casper.test.begin(testName('source-viewer-should-not-show-source-if-no-permissio
|
||||
});
|
||||
})
|
||||
|
||||
.then(function () {
|
||||
lib.sendCoverage();
|
||||
})
|
||||
|
||||
.run(function () {
|
||||
test.done();
|
||||
});
|
@ -61,6 +61,10 @@ casper.test.begin(testName('source-viewer-should-open-in-new-window-with-line'),
|
||||
});
|
||||
})
|
||||
|
||||
.then(function () {
|
||||
lib.sendCoverage();
|
||||
})
|
||||
|
||||
.run(function () {
|
||||
test.done();
|
||||
});
|
@ -55,6 +55,10 @@ casper.test.begin(testName('source-viewer-should-open-in-new-window'), function
|
||||
});
|
||||
})
|
||||
|
||||
.then(function () {
|
||||
lib.sendCoverage();
|
||||
})
|
||||
|
||||
.run(function () {
|
||||
test.done();
|
||||
});
|
@ -65,6 +65,10 @@ casper.test.begin(testName('Base'), function (test) {
|
||||
});
|
||||
})
|
||||
|
||||
.then(function () {
|
||||
lib.sendCoverage();
|
||||
})
|
||||
|
||||
.run(function () {
|
||||
test.done();
|
||||
});
|
||||
@ -110,6 +114,10 @@ casper.test.begin(testName('Decoration'), function (test) {
|
||||
test.assertExists('.source-line-scm-inner[data-author="julien.henry@sonarsource.com"]');
|
||||
})
|
||||
|
||||
.then(function () {
|
||||
lib.sendCoverage();
|
||||
})
|
||||
|
||||
.run(function () {
|
||||
test.done();
|
||||
});
|
||||
@ -135,6 +143,10 @@ casper.test.begin(testName('Test File'), function (test) {
|
||||
test.assertSelectorContains('.source-viewer-header-measure', '6');
|
||||
})
|
||||
|
||||
.then(function () {
|
||||
lib.sendCoverage();
|
||||
})
|
||||
|
||||
.run(function () {
|
||||
test.done();
|
||||
});
|
@ -69,6 +69,9 @@ casper.test.begin('Treemap', function (test) {
|
||||
test.assertSelectorHasText('.treemap-cell', 'Server');
|
||||
test.assertElementCount('.treemap-cell', 25);
|
||||
});
|
||||
})
|
||||
.then(function () {
|
||||
lib.sendCoverage();
|
||||
});
|
||||
|
||||
casper.run(function() {
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user