5

我正在使用 Karma 进行一些单元测试并生成代码覆盖率统计信息。当我在没有 karma 配置中的代码覆盖设置的情况下从命令行运行测试时,我可以在命令行中看到测试结果。IE

Executed 3 of 3 SUCCESS (0.465 secs / 0.048 secs)

当我将代码覆盖率设置添加到配置并运行测试时,会生成覆盖率文件,但我没有在命令行中看到测试结果。

我的配置是:

basePath = '../';

files = [
    JASMINE,
    JASMINE_ADAPTER,
    'https://ajax.googleapis.com/ajax/libs/angularjs/1.0.1/angular.min.js',
    'app/lib/angular/angular.js',
    'app/lib/angular/angular-scenario.js',
    'test/lib/angular/angular-mocks.js',
    'app.js',      // include app first as other module hang off it
    'public/javascript/**/*.js',
    'test/unit/**/*.js'
];

/* code coverage settings */
preprocessors = {
    '**/public/javascript/**/*.js': 'coverage'
};

reporters = ['coverage']; 
/* end code coverage settings */

autoWatch = true;

browsers = ['Chrome'];

junitReporter = {
    outputFile: 'test_out/unit.xml',
    suite: 'unit'
};

我可以创建单独的脚本来生成代码覆盖率并运行测试,在速度等方面我最好这样做,但我想知道我是否可以一起做,如果可以的话我错过了配置的东西吗?

4

1 回答 1

4

When you added the "coverage" reporter in your config it seems you removed the "progress" reporter that used to be there by default.

Just change the reporters part of your config to:reporters = ['coverage','progress'] instead of reporters = ['coverage']

于 2013-09-16T13:20:36.483 回答