Skip to content

Commit 225ce00

Browse files
committed
【update】sonar ut report review by xiongjj
1 parent 6b869b2 commit 225ce00

File tree

3 files changed

+37
-29
lines changed

3 files changed

+37
-29
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@
9393
"karma-cli": "^2.0.0",
9494
"karma-coverage": "^2.0.1",
9595
"karma-jasmine": "^2.0.1",
96+
"karma-sonarqube-unit-reporter": "0.0.21",
9697
"karma-teamcity-reporter": "^1.1.0",
9798
"mock-socket": "^9.0.2",
9899
"nightwatch": "^1.3.1",

sonar-project.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ sonar.sourceEncoding=UTF-8
1717
sonar.host.url=https://sonar9001.ispeco.com
1818

1919
sonar.profile=Sonar way
20+
sonar.testExecutionReportPaths=test/testcoverage/ut_report.xml
2021
sonar.javascript.lcov.reportPath=test/testcoverage/lcov.info
2122
# SINCE SONARQUBE 6.2 WITH SONARJS 2.19+
2223
sonar.javascript.lcov.reportPaths=test/testcoverage/lcov.info

test/karma.conf.js

Lines changed: 35 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ module.exports = function (config) {
55
// 设置测试的超时时间
66

77
config.set({
8-
98
// base path that will be used to resolve all patterns (eg. files, exclude)
109
basePath: '',
1110

@@ -22,12 +21,23 @@ module.exports = function (config) {
2221
browserify: {
2322
debug: true,
2423
transform: [
25-
[require('babelify'), {
26-
global: true,
27-
presets: ["@babel/preset-env"],
28-
ignore: ["../src/classic/libs/**", "../test/libs/**", "../node_modules/mapbox-gl/**","../node_modules/three/**","../node_modules/xlsx/**","../node_modules/@turf/**","../node_modules/lodash/**"],
29-
plugins: ['istanbul']
30-
}],
24+
[
25+
require('babelify'),
26+
{
27+
global: true,
28+
presets: ['@babel/preset-env'],
29+
ignore: [
30+
'../src/classic/libs/**',
31+
'../test/libs/**',
32+
'../node_modules/mapbox-gl/**',
33+
'../node_modules/three/**',
34+
'../node_modules/xlsx/**',
35+
'../node_modules/@turf/**',
36+
'../node_modules/lodash/**'
37+
],
38+
plugins: ['istanbul']
39+
}
40+
],
3141
[require('browserify-css'), { global: true }],
3242
require('browserify-imgify')
3343
]
@@ -41,9 +51,9 @@ module.exports = function (config) {
4151
'./resources/img/**.png',
4252
/***classic的源码***/
4353
/*由于除了classic其他都不依赖于8c,所以classic 的引入放在最后,以免被common覆盖*/
44-
{pattern: '../src/classic/libs/SuperMap_Basic-8.1.1-17729.js', include: false},
45-
{pattern: '../src/classic/libs/Lang/*.js', include: false},
46-
{pattern: '../src/classic/theme/default/*.css', include: false},
54+
{ pattern: '../src/classic/libs/SuperMap_Basic-8.1.1-17729.js', include: false },
55+
{ pattern: '../src/classic/libs/Lang/*.js', include: false },
56+
{ pattern: '../src/classic/theme/default/*.css', include: false },
4757
/**测试文件**/
4858
'./test-main-classic.js',
4959

@@ -53,22 +63,22 @@ module.exports = function (config) {
5363
'./test-main-common.js',
5464

5565
/***leaflet的源码***/
56-
{pattern: './libs/workers/TurfWorkerForTest.js', include: false},
57-
{pattern: '../node_modules/leaflet/dist/leaflet.css', include: false},
58-
{pattern: '../src/leaflet/**/**/*.css', include: false},
66+
{ pattern: './libs/workers/TurfWorkerForTest.js', include: false },
67+
{ pattern: '../node_modules/leaflet/dist/leaflet.css', include: false },
68+
{ pattern: '../src/leaflet/**/**/*.css', include: false },
5969
'../src/leaflet/**/!(index).js',
6070
/**测试文件**/
6171
'./test-main-leaflet.js',
6272

6373
/***openlayers的源码***/
64-
{pattern: '../node_modules/ol/ol.css', include: false},
65-
{pattern: '../src/openlayers/**/**/*.css', include: false},
74+
{ pattern: '../node_modules/ol/ol.css', include: false },
75+
{ pattern: '../src/openlayers/**/**/*.css', include: false },
6676
'../src/openlayers/**/!(index).js',
6777
/**测试文件**/
6878
'./test-main-openlayers.js',
6979

7080
/***mapboxgl***/
71-
{pattern: '../node_modules/mapbox-gl/dist/mapbox-gl.css', include: false},
81+
{ pattern: '../node_modules/mapbox-gl/dist/mapbox-gl.css', include: false },
7282
'../src/mapboxgl/**/!(index).js',
7383
/**测试文件**/
7484
'./test-main-mapboxgl.js'
@@ -112,7 +122,7 @@ module.exports = function (config) {
112122
// test results reporter to use
113123
// possible values: 'dots', 'progress'
114124
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
115-
reporters: ['progress', 'coverage', 'teamcity'],
125+
reporters: ['progress', 'sonarqubeUnit', 'coverage', 'teamcity'],
116126

117127
//最大超时时间
118128
captureTimeout: 120000,
@@ -121,41 +131,37 @@ module.exports = function (config) {
121131

122132
coverageReporter: {
123133
dir: 'testcoverage/',
124-
reporters: [
125-
{type: 'lcov', subdir: '.'}
126-
]
127-
}
128-
,
134+
reporters: [{ type: 'lcov', subdir: '.' }]
135+
},
136+
sonarQubeUnitReporter: {
137+
sonarQubeVersion: 'LATEST',
138+
outputFile: 'testcoverage/ut_report.xml',
139+
useBrowserName: false
140+
},
129141

130142
// web server port
131143
port: 9876,
132144

133-
134145
// enable / disable colors in the output (reporters and logs)
135146
colors: true,
136147

137-
138148
// level of logging
139149
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
140150
logLevel: config.LOG_INFO,
141151

142-
143152
// enable / disable watching file and executing tests whenever any file changes
144153
autoWatch: true,
145154

146-
147155
// start these browsers
148156
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
149157
browsers: ['Chrome'],
150158

151-
152159
// Continuous Integration mode
153160
// if true, Karma captures browsers, runs the tests and exits
154161
singleRun: false,
155162

156163
// Concurrency level
157164
// how many browser should be started simultaneous
158165
concurrency: Infinity
159-
160-
})
166+
});
161167
};

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy