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

why code coverage result is different in debug and release versions in visual studio

Am working in Visual Studio 2013. My Build and Running UT is successful. But when i see code coverage results, Debug version is showing 83% and Release version is 70 %. Why so much of difference is coming and whats the solution?
Karma Yogi
  • 615
  • 1
  • 7
  • 18
3
votes
3 answers

Free code coverage tools

Are there any free code coverage tools for native (not managed) code? For either Windows or Linux platforms?
Ferruccio
  • 98,941
  • 38
  • 226
  • 299
3
votes
0 answers

Clover failing with "No Clover database found, skipping report generation"

I'm trying to add Clover to my maven (groovy) project in order to get some code coverage results. However it fails to generate the code coverage report. The report is just empty. My src files are located in src/main/groovy and my tests are located…
user1104939
  • 1,395
  • 2
  • 13
  • 25
3
votes
2 answers

Is there any means by which I could evaluate the test-coverage of drl files in Drools rule engine?

I am trying to derive test-coverage for unit-tests running across rules written in drl files(Drools rule engine). Basically I want to derive the percentage of the rule execution which has been actually covered by the unit tests written around them.…
3
votes
1 answer

Django Coverage ModuleNotFoundError: No module named 'django_extensions'

I've dug through SO posts, I've dug through random obscure blogs and I can't seem to fix my issue here. This is how I went about all this: I created a nice fresh new virtual environment: virtualenv venv I installed all my requirements: pip install…
Hanny
  • 580
  • 3
  • 16
  • 44
3
votes
1 answer

Is it possible to only run the JaCoCo maven plugin during the site lifecycle?

Consider the follow build configuration: org.apache.maven.plugins maven-surefire-plugin ${surefireArgLine} all
Jonathan S. Fisher
  • 8,189
  • 6
  • 46
  • 84
3
votes
1 answer

How do I prevent Pester Mocked Read-Host from prompting for input during Code Coverage

I have a Pester test where I mock up a Read-Host call for my function, which follows the format in this question here: How do I mock Read-Host in a Pester test? Describe "Test-Foo" { Context "When something" { Mock Read-Host {return…
3
votes
1 answer

Incorrect code coverage inside of for loop

Hello fellow overflowers, I'm working on a Swift class whose initializer contains a for loop that runs a certain amount of times according to a parameter of the init. Unfortunately, I cannot show you the exact code, but it's similar to…
RenanGreca
  • 63
  • 4
3
votes
2 answers

Code coverage results not getting updated with Branching in sonarqube

I am working on integrating sonarqube in Jenkins pipeline. I have enabled code coverage on sonarqube with opencover using sonar-csharp as per the documentation below https://docs.sonarqube.org/pages/viewpage.action?pageId=6389770 I am also using the…
3
votes
1 answer

Generating Code Coverage in scrutinizer

I created a little package and I want to get some qualifications for it. So one of them is Scrutinizer Coverage and Code Quality. As in the tutorial I created a file and renamed it to scrutinizer.yml and put the following into it: build: tests: …
Babak no'doust
  • 631
  • 7
  • 18
3
votes
1 answer

How to set coveragerc and/or setup.cfg to test a package with specific tests location

I am implementing tests on a python package and I try to make them with pytest. The project has the following…
3
votes
0 answers

System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage not working on async methods using xunit

Quite straighforward. This is generic code from some sandbox experiments. ExcludeFromCodeCoverage seems to be working properly for synchronhous methods. No runsettings or any configuration related to the coverage are in…
3
votes
1 answer

Why does Istanbul / tap code coverage report a switch statement as not covered when each conditional path is covered?

In a node.js application I have a class with a getter that contains a large switch statement, same as this but larger with unreleased-product-specific values instead of a, b, c, 1, 2, 3 etc: Class SomeClass () { constructor (someVar) { …
user56reinstatemonica8
  • 32,576
  • 21
  • 101
  • 125
3
votes
3 answers

Does one still write tests with TDD when the desired code has little to no logic? Why?

TDD is supposed to have 100% code coverage. Does this mean one is supposed to write tests for property getter and setters, and other methods that contain no real logic, such as dealing with external API functionality? Example 1: Below is one…
Matt
  • 14,353
  • 5
  • 53
  • 65
3
votes
1 answer

Cobertura Unable to Instrument

I am trying to use the Gradle Cobertura Plugin as a code coverage tool on my Springboot application. The application is mostly Java backend but does consist of some groovy code. I am using Java 1.8.0_152, Gradle 4.4, the gradle cobertura 2.5.4…
Brendan Prin
  • 183
  • 3
  • 10