25

我试图让 Karma runner 在 Jenkins 构建期间生成 cobertura 格式的代码覆盖率报告。我可以让它生成一个coverage.xml 文件,但它实际上没有任何覆盖数据。看起来(使用LOG_DEBUG)覆盖预处理器没有运行。

karma.conf.js文件中的相关部分是:

files = [
  JASMINE,
  JASMINE_ADAPTER,
  'app/components/angular/angular.js',
  'app/components/angular-mocks/angular-mocks.js',
  'tmp/scripts/**/*.js',
  'tmp/spec/**/*.js'
];

preprocessors = {
  'tmp/scripts/**/*.js': 'coverage'
};

// test results reporter to use
// possible values: 'dots', 'progress', 'junit'
reporters = ['dots', 'junit', 'coverage'];

junitReporter = {
  outputFile: 'test-results.xml'
};

coverageReporter = {
  type: 'cobertura',
  dir: 'coverage/',
  file: 'coverage.xml'
};

(junit 报告生成良好。)

4

1 回答 1

28

显然,业力代码覆盖率文档比我想象的更字面。将我的preprocessors配置更改为

preprocessors = {
  '**/tmp/scripts/**/*.js': 'coverage'
};

(注意前面的**/)成功了。我不确定为什么files数组和preprocessors对象('tmp/scripts/**/*.js'vs. '**/tmp/scripts/**/*.js')的语法不同。

于 2013-03-26T22:41:21.420 回答