【问题标题】:lcov.info not getting scanned by sonarqubelcov.info 没有被 sonarqube 扫描
【发布时间】:2019-09-21 09:25:45
【问题描述】:

我正在尝试在 sonarqube 上使用 coverageIstanbulReporter 扫描我的代码的覆盖范围。这是我的 karma.conf.js 文件:

module.exports = function (config) {
config.set({
    basePath: '',
    frameworks: ['jasmine', '@angular/cli'],
    plugins: [
        require('karma-jasmine'),
        require('karma-chrome-launcher'),
        require('karma-jasmine-html-reporter'),
        require('karma-coverage-istanbul-reporter'),
        require('@angular/cli/plugins/karma')
    ],
    client: {
        clearContext: false // leave Jasmine Spec Runner output visible in browser
    },
    coverageIstanbulReporter: {
        reports: ['html', {
            'lcovonly': {
                "directory": "coverage",
                "filename": "lcov.info",
                "subdirectory": "lcov"
            }
        }],
        fixWebpackSourcePaths: true
    },
    angularCli: {
        environment: 'dev'
    },
    reporters: ['progress', 'kjhtml', 'dots'],
    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: true,
    browsers: ['Chrome'],
    singleRun: false
});
};

我的 build.gradle 文件有声纳的属性:

sonarqube {
properties {
    // Sonar Specific properties
    property 'sonar.host.url', '' // This is the Sonar Server
    property "sonar.projectName", ""
    property "sonar.projectKey", ""
    property "sonar.sources", "./src"
    property "sonar.exclusions", "**/*.spec.js,**/test.ts,"
    property "sonar.language", "ts"
    property "sonar.typescript.lcov.reportPaths", "coverage/lcov/lcov.info"
    property "sonar.test.inclusions", "**/*.spec.ts"
}
}

现在,问题是,声纳的覆盖范围并不能反映我测试的覆盖范围。此外,在本地运行时,我无法在我的机器中看到 coverage/lcov/lcov.info 文件。

我不确定我的代码出了什么问题。

【问题讨论】:

    标签: typescript karma-jasmine sonarqube-scan karma-coverage lcov


    【解决方案1】:

    您是否使用此命令运行单元测试

    ng test --code-coverage
    

    这应该会生成 lcov.info 文件。

    【讨论】:

      猜你喜欢
      • 2018-07-01
      • 1970-01-01
      • 2016-12-10
      • 1970-01-01
      • 2017-02-20
      • 2018-07-04
      • 2017-02-12
      • 2017-10-08
      • 2018-08-01
      相关资源
      最近更新 更多