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?
Related
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.
I have jenkins file which has publishHTML method to generate report with .html file of jacoco result. Is it possible to display that report on dashboard like 'Test Trend Result' ?
So I went through a bit then found a solution adding to the pipeline directly
publishCoverage adapters: [jacocoAdapter('target/site/jacoco/jacoco.xml')]
Reference: https://github.com/jenkinsci/code-coverage-api-plugin
You need to use the JaCoCo plugin
Get coverage data as part of your build First you need to get coverage
calculated as part of your build/tests, see the JaCoCo documentation
for details. You need at least one or more *.exec file available after
tests are executed. Usually this means adjusting your Maven pom.xml or
Ant build.xml file..
Set up coverage retrieval and publishing In order to get the coverage
data published to Jenkins, you need to add a JaCoCo publisher and
configure it so it will find all the necessary information. Use the
help provided via the question-mark links for more information.
Basically you specify where the *.exec files are, where compiled code
can be found and where the corresponding source code is located after
the build is finished to let the plugin gather all necessary pieces of
information..
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
I use JaCoCo for IT coverage in Sonar in Java language. Some IT code coverage is reported, and the reported results appear to be sound. However, I noticed that not all source code was included in the IT coverage analysis. Looking at the "Components" view, many Java packages show rules %, cobertura unit test coverage %, but nothing for IT coverage. I have not included or excluded any files, I would therefore expect IT coverage to show 0% if no code from this package was covered? I know there should be some % on a set of files, but Sonar does not display anything for it (again, rules % and cobertura % are shows).
I will try to explicitly include some class files, but I am still puzzled regarding why all sources are not included for JaCoCo analysis. The files are imported to Sonar because rules violations work fine on them.
I guess that if you do not see any results on some specific files/packages, this probably means that no IT covers those parts of your source code.
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.