lcov.info没有被sonarqube扫描

时间:2019-05-02 20:06:16

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

我正在尝试使用声纳上的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文件。

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

1 个答案:

答案 0 :(得分:0)

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

ng test --code-coverage

这应该产生lcov.info文件。