Code coverage for C++ using MSVS tools

Hi,
I'm using command line tools to get code coverage report. actually it is VSInstr and VSPerfCmd. as a result I get binary file which can be converted into XML coverage report. All above will be launched as a build step using Teamcity. Adding it to our CI has any meaning only in case I can generate human readable report and display it as a tab in teamcity or sending as mail. so, actually the question is if there is any possibility to create report from aforementioned XML in TeamCity?

3 comments
Comment actions Permalink

Hi

For coverage reports there are two parts of the task:
1) To display readable coverage reports in TeamCity UI you'll need to make your coverate tool to export reports in HTML format, pack them to zip archive, publish the archive as a build artifact, and register new custom tab. Please find details in Including Third Party Reports in the Build Results article.

2) Coverage data needs to be explicitly imported into TeamCity to be displayed in build statistics, and used in build failure confitions. For that your build script should parse XML report your tool provide, and extract values for total items, covered items, and resulted ratio. Then they should be send to TeamCity by service messages. Each kind of coverage statistics is reported by separate blocks of messages, including:

Statement coverage

##teamcity[buildStatisticValue key='CodeCoverageS' value='<value>']
##teamcity[buildStatisticValue key='CodeCoverageAbsSCovered' value='<value>']
##teamcity[buildStatisticValue key='CodeCoverageAbsSTotal' value='<value>']

Line coverage
##teamcity[buildStatisticValue key='CodeCoverageL' value='<value>']
##teamcity[buildStatisticValue key='CodeCoverageAbsLCovered' value='<value>']
##teamcity[buildStatisticValue key='CodeCoverageAbsLTotal' value='<value>']

Block coverage
##teamcity[buildStatisticValue key='CodeCoverageB' value=' <value>']
##teamcity[buildStatisticValue key='CodeCoverageAbsBCovered' value='<value>']
##teamcity[buildStatisticValue key='CodeCoverageAbsBTotal' value='<value>']

Method coverage
##teamcity[buildStatisticValue key='CodeCoverageM' value='<value>']
##teamcity[buildStatisticValue key='CodeCoverageAbsMCovered' value='<value>']
##teamcity[buildStatisticValue key='CodeCoverageAbsMTotal' value='<value>']

Class coverage
##teamcity[buildStatisticValue key='CodeCoverageC' value='<value>']
##teamcity[buildStatisticValue key='CodeCoverageAbsCCovered' value='<value>']
##teamcity[buildStatisticValue key='CodeCoverageAbsCTotal' value='<value>']


Please let me know if more detailed example is required.
0
Comment actions Permalink

you guys rock! I knew there should be an answer for this problem :)
just to make couple of things clear. Two parts of your answer are unrelated, right? I can implement either the first with html or the second with service messages or both.
the first task, as I understand, can be easily achieved by using xslt which produces the html. the second one can be relatively easily achived by writing any command line utility which writed the messages to stdout, correct?

0
Comment actions Permalink

You are right in all the questions.
The parts are indemendent, but more valuable together.

Most of the coverage tools support HTML format out of the box, or at least provide XSLT scripts, you can find many such examples.
Service messages are sent to TeamCity by stdout, so you can use any scripting language for that.

0

Please sign in to leave a comment.