iOS Unit Test Coverage - Sonar Report - xccov - ios

xccov tool generates the unit test coverage report for covered lines of code only. So if example.swift file has 20 lines, and 10 is covered by unit tests the coverage will be 50%.
Karma (used in Angular 2 development) creates report not just for lines of code covered, but also statements, branches and functions.
Is it possible to config xccov, or is there a similar tool to achieve this in iOS development? Thanks!

Xccov don't generate any coverage data. Xccov can read coverage reports from tool xcodebuild:
To get coverage data you should select gather coverage data at your test scheme:
At your CI script you can add flag -resultBundlePath to select folder where coverage data will save.
Then you can use xccov to get following information:
Overall target coverage by xccov view --only-targets report.xccovreport
Coverage by file xccov view --files-for-target target_name report.xccovreport
Coverage for each function xccov view --func-
tions-for-file name_or_path report.xccovreport
Raw coverage data line by line xccov view --file file_name report.xccovarchive
You can use --json flag to analyze results by script.
For more information about xccov you can read man xccov or watch the WWDC session What's New in Testing
So, xccov give you statistics for functions out the box. If you want more. For example, statistic for statements and branches you can create script by yourself using SourceKit and xccov data. SourceKit can give an information about AST of source code and where statement are located. By the location you can match information about coverage through xccov report.

Related

How to do full codebase code coverage scan using azurepipelines-coverage.yml

Reference:
https://learn.microsoft.com/en-us/azure/devops/pipelines/test/codecoverage-for-pullrequests?view=azure-devops
https://github.com/MicrosoftDocs/codecoverage-yaml-samples
The links above, only talk about diff coverage as part of Pull request. My questions are as follows:
1. How can we configure YAML to do full coverage instead of differencial coverage and produce the output in PR
2. When diff coverage is run, it is even considering files where [ExcludeFromCodeCoverage] is mentioned as attributes. Do we have any settings for this to be excluded from target percentage?

Is it possible to show trends from an lcov report in jenkins?

I have an lcov report which produces a pretty html report and an lcov.info file. I want to see on jenkins whether our code coverage is improving or degrading. Is it possible to do this with an lcov report? I can do it using cobertura, but for various reasons we need to stick with lcov. We also need to see statements, branches, functions and lines.
The coverage report is being produced by istanbul/nyc.

Aggregate jmockit-coverage output with emma coverage output

Is there a way to aggregate code coverage data from jmockit-coverage and emma coverage? I can run the two different coverage steps in two separate junit ant tasks and generate the coverage data in two directories. Just not sure if the coverage outputs from these two are compatible and can be merged to display together.
No, they can't be aggregated into a single HTML report, since these are two different code coverage tools, which know nothing about each other. Of course, someone could create yet another tool which would do that; personally, I don't see much value in it, though.

Using gcovr to show zero coverage

we try to use gcovr to generate coverage report for our c++ project in Jenkins.
I was able to get it worked, but I'm stuck with one problem. gcovr doesn't show any statistics for files with zero coverage - they have only .gcno files, no .gcda files are produced and gcovr don't show it in results.
So I have 80% coverage for the whole project, but only 2 tests were written and it's actually 80% coverage only for source files involved in tests.
For large project it makes of course no sense to use such statistic.
I have found https://software.sandia.gov/trac/fast/changeset/2766 this changeset as solution for this ticket https://software.sandia.gov/trac/fast/ticket/3887, but it seems not to be working.
Did I miss something?
p.s. I use gcovr 3.1-prerelease

NCover branch Coverage

I am using the Ncover 2.1.2.3625. I want branch coverage and sequence coverage. How to get this?
The .xml generated is given to the NCoverExplorer to generate the full coverage report.
But the full coverage report is not generated. What is the reason for this?
Branch coverage should be displayed for any successful coverage run, but to get symbol/sequence coverage, the PDB files for the source code must be placed in the directory with the tested assemblies.
A valid coverage file should produce a full coverage report (unless the coverage file is empty). If you can post any error messages, that would help track down the problem.

Resources