在TeamCity上为Karma配置代码覆盖率报告 [英] Configuring code coverage report for Karma on TeamCity

查看:98
本文介绍了在TeamCity上为Karma配置代码覆盖率报告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在设置TeamCity以使用node和karma运行我们的jasmine测试。

We are setting up TeamCity to run our jasmine tests using node and karma.

测试运行正常,结果在TeamCity的测试选项卡下报告。

The tests run fine and results are reported under the "Tests" tab in TeamCity.

但是我们想报告TeamCity中的代码覆盖率(甚至在该级别设置构建失败条件)。

However we would like to report code coverage in TeamCity (and even set Build Failure Conditions on the level).

我已经安装了业力覆盖模块

I have installed the karma-coverage module

npm install karma-coverage --save-dev

并尝试通过添加<在 karma.conf.js 中配置它/ p>

And tried to configure it in karma.conf.js by adding

preprocessors: {
 'myProject/Scripts/app/**/*.js': 'coverage'
},

reporters: ['progress', 'coverage'],

当运行karma时,不会报告任何错误,并且会在 coverage 文件夹下创建大量文件,包括<$ c $中格式良好的代码覆盖率报告c> index.html

When karma is run, no errors are reported, and lots of files are created below the folder coverage, including a very nicely formatted code coverage report in index.html

但TeamCity中没有任何新内容。没有代码覆盖率选项卡。

But nothing new shows up in TeamCity. No "Code Coverage" tab.

如何配置karma以生成显示在TeamCity中的报告?

How do I configure karma to produce reports that show up in TeamCity?

也许我可以将set coverageReporter 用于适当的事情,但是什么?
此设置没有区别:

Perhaps I can use set coverageReporter to something appropriate, but what? This setting makes no difference:

coverageReporter: {
    type : 'html',
    dir : 'coverage/'
},

奖金问题:如何设置Build业力报告代码覆盖率的失败条件?

Bonus question: how do I set Build Failure Conditions on the karma reported code coverage?

推荐答案

让TeamCity识别您的覆盖率报告的最简单方法是输出构建包含那个漂亮的html覆盖率报告的工件。

The easiest way to get TeamCity to recognize your coverage report is to output a build artifact that contains that nice html coverage report.

编辑构建的配置设置,并在工件路径下添加如下内容:

Edit the configuration settings for your build and under Artifact Paths add something like:

coverage/** => coverage.zip

如果找到index.html文件,TeamCity将识别coverage.zip工件。 root并将为每个版本添加代码覆盖率选项卡。

TeamCity will recognize the coverage.zip artifact if it finds the index.html file in the root and will add a Code Coverage tab to each build.

来源: https://confluence.jetbrains.com/pages/viewpage.action?pageId=74847395#HowTo...-ImportcoverageresultsinTeamCity (Teamcity version 9.x)

Source: https://confluence.jetbrains.com/pages/viewpage.action?pageId=74847395#HowTo...-ImportcoverageresultsinTeamCity (Teamcity version 9.x)

这篇关于在TeamCity上为Karma配置代码覆盖率报告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆