Questions tagged [code-coverage]

"Code coverage" (synonym: test coverage) is a measure of the amount of application source code that has been exercised, usually by some testing regime, often by unit testing.

Code coverage is a measure of the amount of application source code that has been exercised, usually by some testing regime, often by unit testing. There are two key questions: given an exercise regime, how much of the source code is executed (under the assumption that the exercise also shows the program effects to be correct), and, given an exercise regime, how does one increase the coverage amount by modifying the exercise.

Determining the actual coverage is normally accomplished by instrumenting the source code to track when its elements are executed, and then simply running the exercise regime. The instrumented data is collected and often displayed in a report and/or a visual display.

Improving coverage given a specific exercise regime is difficult. One must determine for some block of uncovered code, how to cause that code to be executed, often requiring a complex initialization of the program environment to trigger the code block.

Code coverage is also known as , but see that tag's wiki for an alternate meaning.

5306 questions
3
votes
1 answer

SonarQube does not correctly import coverage.xml file for Python project

I'm working on a Python project on Linux. I'm trying to link the coverage.xml report to SonarQube analysis. The project structure is the following: - root - folder1 ... - folder2 ... - ... - coverage.xml I run the…
Giordano
  • 5,422
  • 3
  • 33
  • 49
3
votes
1 answer

How to exclude auto generated Dao and view binding classes from Jacoco code coverage report?

I am trying to exclude Dao files generated by Room from Jacoco code coverage report. But exclude is not working. Here is my task: task jacocoTestReport(type: JacocoReport, dependsOn: ['testDebugUnitTest', 'createDebugCoverageReport']) { reports…
3
votes
2 answers

How to publish coverage report from gitlab CI artifacts folder?

I am following the following tutorial to create code coverage report: Publish code coverage report with GitLab Pages My .gitlab-ci.yml file looks same as in the tutorial, except that I am doing it in python image: ubuntu:18.04 variables: …
some_programmer
  • 3,268
  • 4
  • 24
  • 59
3
votes
1 answer

zsh: command not found: genhtml (Flutter + Code Coverage using Codemagic)

I'm new in DevOps, I want to create code coverage from unit testing result in Flutter. And this is our command to run that: flutter test --coverage && genhtml coverage/lcov.info --output=coverage And this is the result: 00:03 +1: All tests passed! …
R Rifa Fauzi Komara
  • 1,915
  • 6
  • 27
  • 54
3
votes
2 answers

Make pytest require code coverage only on full test suite run

I am using something like # .coveragerc fail_under = 100 and # pytest.ini [pytest] addopts = --cov=modname/ --cov-report=term-missing to make it so that my test suite runs the coverage and fails if it isn't 100%. This works, but the problem is…
asmeurer
  • 86,894
  • 26
  • 169
  • 240
3
votes
1 answer

Why is the code coverage value of fastlane xcov different from Xcode's value for the same scheme?

When I run my tests inside Xcode the code coverage is 10.3%. When running fastlane run xcov for the same scheme the code coverage is 17.17%. The xcov html file shows the same files with the same coverage percentages, only the total coverage is…
fuesev
  • 153
  • 6
3
votes
2 answers

How to publish Cobertura coverage report from the VS coverage produced by dotnet test --collect "Code coverage"?

So the process can be deduced from https://learn.microsoft.com/en-us/azure/devops/pipelines/ecosystems/dotnet-core?view=azure-devops#collect-code-coverage and contains of the following steps: Run the tests with coverage without publishing the test…
mark
  • 59,016
  • 79
  • 296
  • 580
3
votes
2 answers

How to set a custom coverage result file path when running dotnet test --collect "Code coverage"?

I followed the instructions on http://tdc1tfsapp01:8080/tfs/DefaultCollection/SharpTop/_packaging?_a=package&feed=dayforce&package=OrchardCore.Cms.Web&version=1.0.20098.7+1bcd36b1f8efd5484af49f8ec39c21060a64391e&protocolType=NuGet and it does…
mark
  • 59,016
  • 79
  • 296
  • 580
3
votes
1 answer

Code coverage Cypress and Storybook, can't instrument my code

I'm trying to work with Cypress and Storybook for visual testing in a React Typescript project. The main goal is to render all my components library with Storybook and then visit them through Cypress and have the code coverage in order to pass it…
3
votes
1 answer

What is the most convenient way to open a Jest Icov coverage report from Visual Studio Code?

Ok, so here is the generic way: run jest --coverage or wrap it as a package.json script and run that Report is generated, navigate to coverage/Icov-report and open index.html you can have an 'open in browser' extension installed, that way you can…
user1762820
  • 223
  • 3
  • 8
3
votes
0 answers

Create a Generic Base XCTestCase doesn't count as covered code

I have a lot of models in my project which are Decodable. I have to write tests to ensure their parsing from a json. What I did is: Create a folder to store my mocked json files for tests. Create a BaseModelTests: XCTestCase where T: Decodable…
3
votes
0 answers

Attaching jacoco agent to a running JVM

Two part question: 1) I have the requirement to attach the jacoco agent to an already running JVM, and per this comment on a Github issue, this was not possible as of 26th July 2018. Has support for this been implemented in the v0.8.5? Because the…
user9492428
  • 603
  • 1
  • 9
  • 25
3
votes
1 answer

How to exclude the django libraries from coverage

Learning django as a part of it developing an app with TDD approach, after going through many internet pages I have chosen unittest for testing and coverage library to know the test covered. The problem is after executing the coverage run and…
ivardu
  • 179
  • 2
  • 15
3
votes
1 answer

Jacoco giving 0% coverage and Intellij Idea gives very less coverage

I am using android studio 3.5.3. After writing unit tests I made sure that unit tests are hitting most of the lines by debugging test cases but coverage is 11% which is very less for my case. Am getting these messages in ide ---- IntelliJ IDEA…
Tarun Chawla
  • 508
  • 4
  • 17
3
votes
0 answers

Excluding a Module from clover code coverage

I have a maven project for which I am trying to find the code coverage using clover plugin. I want to exclude coverage for a specific module. The module I want to exclude basically contains Util classes for tests and I don't want them to be part of…
Kunal gupta
  • 481
  • 2
  • 7
  • 19