将 Protractor E2E 测试代码覆盖添加到 SonarQube

Add Protractor E2E test code coverage to SonarQube

我想要 Protractor E2E 测试来反映我在 SonarQube.

中的代码覆盖率

我试过 grunt-protractor-coverage npm 模块,但它显示 100% 的覆盖率,而它创建的报告文件是空的。

这是我 Gruntfile.js 的相关部分:

connect: {
            options: {
                port: 9000,
                hostname: 'localhost'
            },
            runtime: {
                options: {
                    base: 'instrumented/build'
                }
            }
        },
        instrument: {
            files: 'build/**/*.js',
            options: {
                lazy: true,
                basePath: "instrumented"
            }
        },
        protractor_coverage: {
            options: {
                keepAlive: true,
                noColor: false,
                coverageDir: 'coverage',
                args: {
                    baseUrl: 'http://localhost:9000'
                }
            },
            local: {
                options: {
                    configFile: './protractor-chrome-conf.js'
                }
            }
        },
        makeReport: {
            src: 'coverage/*.json',
            options: {
                type: 'lcov',
                dir: 'coverage/dir',
                print: 'detail'
            }
        } 

有什么想法吗?

您必须先安装 SonarJS code analyzer

然后可以为该插件提供提供覆盖信息的 LCOV 报告:http://docs.sonarqube.org/display/PLUG/JavaScript+Coverage+Results+Import